LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine if Ctrl key is pressed.

I want to perform some actions when handling Mouse Move event only when Ctrl key is pressed. Is there a way to determine pressed state of Ctrl key?

0 Kudos
Message 1 of 6
(4,618 Views)

Since you're already using an event structure (presumably in a loop), the easiest thing would be to add a Key Down and Key Up event and use that to toggle a boolean flag which will be in a shift register. Then you look at that flag in the mouse move event. I'm not sure whether the Ctrl key is in the list of keys returned by the terminal, but there should be a special terminal for modifiers which should give you the Ctrl state.


___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(4,616 Views)

This does not look nice. I am sure there can be a way to get current keyboard state. Isn't it?

0 Kudos
Message 3 of 6
(4,591 Views)

Hi jonni,

 

"This does not look nice"

The user doesn't see the block diagram, so the look is irrelevant...

 

"a way to get current keyboard state"

- The MouseUp/Down events already give states of Ctrl and Shift keys.

- Use the input device VIs to poll the current keyboard state...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(4,587 Views)

Even if user does not see our code I think it still needs to be nice and clean.

 

I do not use Mouse Up/Down, I use Mouse Move.

 

Looks like only input devices vis are straight forward solution.

0 Kudos
Message 5 of 6
(4,557 Views)

Hi Jonni,

 

I've attached a simple example VI that uses the Mouse Move event filter to check for mouse movement and calls user32.dll to check if CTRL key is pressed. I think that is what you are looking for.

 

 

Sev K.
Senior Systems R&D Engineer | Wireless | CLA
National Instruments
0 Kudos
Message 6 of 6
(4,543 Views)