LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

key down in event structure

Solved!
Go to solution
Highlighted

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

0 Kudos
Message 1 of 13
(7,578 Views)
Solution
Accepted by pawhan11

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.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 13
(7,570 Views)
Highlighted

So simple 😄

Big thanks

 

0 Kudos
Message 3 of 13
(7,563 Views)
Highlighted

Here's what I had in mind. Modify as needed.

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Download All
Message 4 of 13
(7,560 Views)
Highlighted
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?
Thanks
uday
0 Kudos
Message 5 of 13
(7,255 Views)
Highlighted

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


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 6 of 13
(7,245 Views)
Highlighted
-Yes, only Left+Up+Down, Left+Down+Up, Down+Up+Left and Down+Left+Up combinations failed in three key combinations.
Thanks
uday
0 Kudos
Message 7 of 13
(7,240 Views)
Highlighted

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

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 8 of 13
(7,212 Views)
Highlighted

OK, this seems to be a limitation of the keyboard hardware and the term is Keyboard Ghosting.

 

See this explanation by mycrosoft.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 9 of 13
(7,198 Views)
Highlighted

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

0 Kudos
Message 10 of 13
(7,192 Views)