Hello everyone, I've stumbled upon a problem, it's that I don't know how to detect if multiple keys have been pressed. Like you've might have seen in programs that they use CTRL+S or something. Now how would I do this? can someone give me some code example? do I have to modify os.pullEvent/pullEventRaw or something todo this?
I tried doing this in some weird way using timers, problem was I couldn't hold down a key. ( for example hold down shift, then press left. I had to press shift and then press left )
And if you're wondering if I have to code left to show I can tell you right now that the answer is nope. The code got deleted as it was a test-script and it didn't work.
- Thanks in advance, TheOddByte
Detecting multiple key presses
Started by TheOddByte, Aug 31 2014 02:21 AM
3 replies to this topic
#1
Posted 31 August 2014 - 02:21 AM
#2
Posted 31 August 2014 - 02:42 AM
There's not really a way to do that in CC (though somewhere on the forums I've seen someone jury-rig it). The best bet is just to see if someone's pressed the two keys within some time of each other.
#3
Posted 31 August 2014 - 03:23 AM
There's one exception (and only one) that comes to mind - holding down Ctrl while pressing characters generates key events for those characters, but not char events.
This means that if you rig your script to queue a custom event whenever a key event is detected, then see whether a char event can be pulled before that custom event, you can tell whether a given character was held in conjunction with Ctrl or not.
This means that if you rig your script to queue a custom event whenever a key event is detected, then see whether a char event can be pulled before that custom event, you can tell whether a given character was held in conjunction with Ctrl or not.
#4
Posted 31 August 2014 - 05:04 PM
Thanks for the help, I gave it a shot and this was the result.
Spoiler
It's not perfect, but it kinda works Edited by TheOddByte, 31 August 2014 - 05:08 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











