Example Code

Navigating the Front Panel with a Keyboard at Runtime in LabVIEW

Code and Documents

Attachment

Overview:

This VI exemplifies how to change the position of the front panel based on a user input to the keyboard.

Description:

This VI uses the Key Down event from the event structure. After a key is pressed, the event structure checks the code of the particular key (the Scan Code).
This Scan Code is checked against the entries of the case structure. If a match is found, the code increments or decrements the position of the front panel's top edge.
If no match is found, nothing happens (empty case).
In this case, the Scan Codes 73 and 81 correspond to the Page Up and Page Down keys on a Dell standard
keyboard. When either is pressed, the position of the front panel changes by the number of specified in the Increment Size control.

Requirements:

LabVIEW Base Development System.

Steps to Implement or Execute Code:
1. Run the VI.
2. Press the Page Up and Page Down keys from the keyboard.
Notes:
1. The scan code indicator shows the code that corresponds to the key being pressed at any time in case your keyboard has different codes for some reason.
2. The 3 and 9 keys in the numeric keypad also have Scan Codes of 73 and 81 so they also trigger the case structure.
3. The event type used here is notify. This means it occurs after the key press has been registered.


Additional Information or References: Snippet 8783.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Verne D. // Software R&D // National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.