10-21-2012 12:41 PM
Hello
I am using arrows on my keyboard to controll program (UP DOWN LEFT RIGHT)
By using key down in event structure i know what button is pressed
But I need to detect that 2 buttons are pressed in the same time to make diffrent cases for that. I dont know haw to handle that.
Any suggestions appreciated
Solved! Go to Solution.
10-21-2012 12:56 PM - edited 10-21-2012 01:33 PM
Keep an array of four booleans in a shift register, then turn each element on or off depending on key press or key release events. The number of true booleans will tell you the state of all buttons at all times.
10-21-2012 01:07 PM
So simple 😄
Big thanks
10-21-2012 01:09 PM - edited 10-21-2012 01:10 PM
12-16-2013 03:04 AM
12-16-2013 03:27 AM
@udka wrote:
Sorry altenbach for digging this old thread again.
-The code which you gave works for all 2 key combinations.
-Tried for three key combinations (i didn't know whether it will also come into same category or not) Luckily most key combinations worked.
-Except which involves Left-Up-Down key events. all these combinations failed.
-Strangely i didn't get any scan code in these specific events for third button press.
-Any thought on this?
Interesting. There must be some deeper limitations somewhere. Not sure if it is LabVIEW or windows. (maybe somebody could try on mac or linux)
All two-key combinations work, I can do "up+down+right" and "left+down+right" from all possible three key combinations. All four keys never works.
Maybe somebody from NI can comment.
12-16-2013 03:45 AM
12-16-2013 04:41 PM
Well, it seems to get more complicated.
Under windows 7, things seem to work just fine and I can light up all LEDs at once. The problem only occurs under windows 8. What is your OS.
Digging deeper (under windows 7), it seems that the number of possible simultanous down keys is random and between 3 and 6, depending on the keys.
For example, we can hold down in sequence a+s+d+f+g+j, but not a+s+d+f+g+h (the "h" is no longer recognized).
12-16-2013 05:02 PM
OK, this seems to be a limitation of the keyboard hardware and the term is Keyboard Ghosting.
12-16-2013 05:11 PM
On my Mac (27" iMac with Apple keyborad with numeric keypad and arrow keys), (OS X 10.8.5) and LV 2013 (32-bit) the scan codes are left = 123, right = 124, down = 125, and up = 126. Afer changing the array in altenbach's VI to those values, the VI runs.
All the 2-arrow combinations work. Left+Right+Up and Left+Right+Down work. Up+Down works. No three arrow combination with both Up and Down works and the 4-arrow combination does not work.
Running with execution highlighting on (patience, please) shows that the event structure does not fire when the third or fourth key in the non-working combinations is pressed. This makes me think it may be an OS issue - not generating the interupt for the keypress.
Lynn