From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift and Ctrl don't generate EVENT_KEYPRESS

Solved!
Go to solution

Hello,

 

I have problem in generating EVENT_KEYPRESS from Shift and Ctrl keys. Other keys generate this event as expected. 

 

Here is code that I used:

 CVICALLBACK panelCB (int panel, int event, void *callbackData,
		int eventData1, int eventData2)
{	
	if (event == EVENT_CLOSE)
	{	
	     QuitUserInterface (0);
	}
	
	if(event == EVENT_KEYPRESS)
	{
	     MessagePopup("title", "Some message");
	}
	
	return 0;
}

 

0 Kudos
Message 1 of 2
(1,027 Views)
Solution
Accepted by topic author Buch99

You're right: Shift and Ctrl keys don't generate keypress events; nevertheless, in a keypress event you can detect combinations of such keys with ordinary keys (such as Shift-Tab or Ctrl-A) as you can see in samples\userint\multikey.cws example.

On the other hand, if you want to react to simple Shift or Ctrl keys pressing you can use GetGlobalMouseState () function; unfortunately, this function must be continously polled to detect events as it is not possible to install a callback on these events. See samples\userint\moustate.cws example for reference.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(973 Views)