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

Key events

Started by sci4me, 14 June 2014 - 03:26 AM
sci4me #1
Posted 14 June 2014 - 05:26 AM
There is no key up event right? So, it's not possible to do things like ctrl + x? If so, it really should be added. Seriously.
Lyqyd #2
Posted 14 June 2014 - 05:37 AM
Ctrl-keypresses can be detected by seeing a Ctrl key event, then a printable key event, then NO char event.
sci4me #3
Posted 14 June 2014 - 05:42 AM
Ah, really? Cool! Good to know, thanks!
KingofGamesYami #4
Posted 14 June 2014 - 05:48 AM
Would this be a way of catching one, or am I not getting the idea?

local event = { os.pullEvent( "key" ) }
if event[2] == control then --#insert key code for control
 local second = { os.pullEvent( "key" ) }
 if not os.pullEvent( 'char', 1 ) then
  --#control combination pressed
 else
  --#not control combo
 end
else
 --#not control
end
Lyqyd #5
Posted 14 June 2014 - 05:59 AM
Uh, no. Check out Gopher's ctrlkeys program for a properly structured example.