LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Key Down event doesn't fire while control key is held down

Solved!
Go to solution

I'm trying to write an actor VI that will handle a few keyboard shortcuts for a strong control. For example, Ctrl-A should select all. I was hoping an event structure would allow me to detect that keyboard combination. But Key Down(?) doesn't work: Pressing and holding control fires off the event for Key Down(?), but then pressing any other keyboard character fails to fire the same event.

 

I can make it work using the Key Up event, but this doesn't select the text until after the keys are up, whereas the normal select-all behavior in most applications will do the text selection while the keys are still pressed.

 

Turns out that the need to detect control-key on a key down event exists elsewhere. For example, I have string filtering on arrow keys (do something when an arrow key is pressed while in a strong control), but this prevents the default ctrl-arrow key behavior. I need to detect whether the control key is pressed to keep the expected text-selection behaviors.

 

 

Any ideas?

 

_____________
Creator of the BundleMagic plugin for LabVIEW!
Message 1 of 18
(392 Views)

You can use the customized runtime menu.  It works even the menu bar is not visible.

 

George Zou
Message 2 of 18
(385 Views)

I note that the key-down event won't fire if a control-key shortcut in the menus is in use. However, in my running VI, there are no menus shown. If I make a sample VI, ctrl-a is grayed out (it's an edit-only feature of the LV environment). So seems to me it should work. 

 

Also, if this is normal text-input behavior, it should work out of the box!

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 3 of 18
(385 Views)

The event data for the key down events has a "PlatMods" section that includes ctrl, so you'd look for 'A' with the ctl mod.

0 Kudos
Message 4 of 18
(379 Views)
Solution
Accepted by littlesphaeroid

ctrl-a is grayed out

You have to create a customized menu.  See attached VI.

 

George Zou
Message 5 of 18
(370 Views)

Thanks @avogadro5 but as I mentioned, this does not work on the Key Down event. Have you tried it?

 

@zou Thank you for the suggestion, that looks like it will work, though I'll need to look into creating this menu item programatically.

 
_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 6 of 18
(343 Views)