5 posts
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.
1140 posts
Location
Kaunas, Lithuania
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?
463 posts
Location
Star Wars
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