Showing results for 
Search instead for 
Did you mean: 

How to use keyboard arrow keys -left and right in Event Structures


   I am just a begginner in using LabVIEW, I'm using LabVIEW 2010 and working on WIndows 7 operating system. I want to run a program which basically accesses keyboard arrow keys "UP", "DOWN" , "RIGHT" AND "LEFT" to call an event which triggers a corresponding PWM signal onto the sbRIO 9632 to run a platform -forward, backward, left and right. I am unable to find the events Key Left and Key Right in Event structures, I could only find Key Up and Key Down.

    Your help is greatly appreciated.



0 Kudos
Message 1 of 5

Key Up and Key Down have nothing to do with the direction arrows.  They mean when any key is pressed down, or released up.


In your case, you are interested in 4 particular keys that just happen to be the up, down, left, and right arrow keys.  What you need to do is register for either a key up or key down event, depending on whether you care about when the key is first pressed or when it is released.  Then you use the nodes attached to the inside left side of the event case to determine which key is pressed.  Compare that to your keys of interest and run the appropriate case of a case structure, or do nothing if it is any other key you don't care about.

Message 2 of 5

Key Up and Key Down refer to actually pushing and releasing any key.  You want to use those two events, and check the VKey event data to see whether the key that is pushed or released is Up, Down, Left, or Right.

Message 3 of 5


   I really appreciate all your tips on how to get the event structures working, my program was drastically reduced by the use of Event structures and it's working now. However, I have a small problem:


   We are running a Platform and a Robot arm with NI sbRIO 9632 board, right now we programmed in three levels:


 1) Laptop level, 2) RIO level 3) FPGA Level. 


  I send the PWM signals, Period of FPGA and Acceleration of the Platform: through the shared variables, I collect the encoder readings through the shared variables too.


  My Laptop level program doesn't seem to respond immediately when I press the arrow keys on keyboard. I have attached the Laptop level program to this file. The file seems to take in all the inputs what I press over the keyboard and it's working fine, but only after a certain large delay, I would really appreciate if you can solve this problem. 

   I would also like to know whether this is caused because of multiple programs open at once in the system or any other external factors. 




0 Kudos
Message 4 of 5

it works fine with me, but i am not happy with the variable present in the while loop. Have a timeout case for your event structure if you would like to update those  "network variables" inside the while loop or else you may not get the required behaviour.

Guru (CLA)
0 Kudos
Message 5 of 5