Jump to content




[question] multi-key bindings


  • You cannot reply to this topic
7 replies to this topic

#1 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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


#2 Doyle3694

  • Members
  • 815 posts

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 :(

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 December 2012 - 01:20 AM

View PostDoyle3694, on 16 December 2012 - 01:17 AM, said:

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.

#4 CoolisTheName007

  • Members
  • 304 posts

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...

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 December 2012 - 01:53 AM

View PostCoolisTheName007, on 16 December 2012 - 01:49 AM, said:

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

View PostCoolisTheName007, on 16 December 2012 - 01:49 AM, said:

EDIT: oh, your signature...

you like? :P

#6 CoolisTheName007

  • Members
  • 304 posts

Posted 16 December 2012 - 02:06 AM

View PostTheOriginalBIT, on 16 December 2012 - 01:53 AM, said:

and a later day when its the last feature to implement
What do you mean?

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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

#8 Doyle3694

  • Members
  • 815 posts

Posted 16 December 2012 - 02:50 AM

Yeah that's a very good idea.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users