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

[question] multi-key bindings

Started by theoriginalbit, 16 December 2012 - 12:14 AM
theoriginalbit #1
Posted 16 December 2012 - 01:14 AM
Does anyone know if its possible to do multi-key press bindings?

for example, something like this


event = { os.pullEvent() }

if event[1] == "key" and (event[2] == keys.ctrl and event[2] == keys.c) then
  print("ctrl + c has been pressed")
end
Doyle3694 #2
Posted 16 December 2012 - 01:17 AM
I assume the last event[2] is ment to have a 3 in it, and no, sadly not. Though, a held down key will spam keyevents, which could be used as a check for a held down key. But any easy way that doesn't use up 100 lines? Sadly, nope :(/>
theoriginalbit #3
Posted 16 December 2012 - 01:20 AM
I assume the last event[2] is ment to have a 3 in it, and no, sadly not. Though, a held down key will spam keyevents, which could be used as a check for a held down key. But any easy way that doesn't use up 100 lines? Sadly, nope :(/>

damn :(/> there goes that plan :P/>

{ os.pullEvent() } for a key returns the event and 1 parameter. so the table would look like this { "key", 23 } where 23 is a key code. so that last 2 was deliberate.
CoolisTheName007 #4
Posted 16 December 2012 - 01:49 AM
Well, if you use a multitasking framework, it's easy to run a task in the background that listens for char and key events, and keeps track of the last time a key was pressed. Mine has more than 1000, I think, but that's not a bad thing!
EDIT: oh, your signature…
theoriginalbit #5
Posted 16 December 2012 - 01:53 AM
Well, if you use a multitasking framework, it's easy to run a task in the background that listens for char and key events, and keeps track of the last time a key was pressed. Mine has more than 1000, I think, but that's not a bad thing!

food for thought, and a later day when its the last feature to implement

EDIT: oh, your signature…

you like? :P/>
CoolisTheName007 #6
Posted 16 December 2012 - 02:06 AM
and a later day when its the last feature to implement
What do you mean?
theoriginalbit #7
Posted 16 December 2012 - 02:07 AM
I will get around to implementing the multikey bindings in my program when its the last feature :P/> since all the other features are easier :P/>
Doyle3694 #8
Posted 16 December 2012 - 02:50 AM
Yeah that's a very good idea.