This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ashnwill's profile picture

How can you tell if caps lock is on?

Started by ashnwill, 06 October 2016 - 05:26 PM
ashnwill #1
Posted 06 October 2016 - 07:26 PM
I need to be able to tell if caps lock is on so I can use the 'key' event and have it properly capitalize characters if caps lock is on. Is there any way to do this?

I can't just use the 'char' event.
MKlegoman357 #2
Posted 06 October 2016 - 07:40 PM
Well, there's is no way of knowing it then. Why cannot you use the "char" event, which is meant just for this?
Sewbacca #3
Posted 06 October 2016 - 08:03 PM
With the following code, you should be able to detect if caps lock is changed, but you need the char event, because if the computer starts or if the user left the computer, you can't know if he used caps:

function detectCapsChanged ()
  while true do
	local event, key = os.pullEvent()
	if event == 'key' and key == keys.caps then -- I dunno how exactly is the name in keys
	  CapsChanged() -- A local event handler
	end
  end
end
Edited on 06 October 2016 - 06:04 PM