The PrintScreen key can be detected with keyboard hooks. Call the SetWindowsHookEx API to install the WH_MOUSE_LL WH_KEYBOARD_LL hook.
You can also check whether a key is pressed using the GetKeyState API.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi dears,
I'm using WPF/C# to create a application for checking keyboard's key work correctly.
I have problems with 3 key:
1- Enter Key (placed inside numeric key) : Enter key I can see IsExtended property in debugging mode but I don't have access it in code.
2- PrtSc key : when I press it windows screenshot app will open and I can't check it pressed.
3- Win key : I can check it but after key press start menu will open, I want to check win key pressed without opening start menu.
my code is here :
private void tabItemKeyboard_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
string key = (e.Key == Key.System) ? e.SystemKey.ToString() : e.Key.ToString();
txtKeyPress.Content = key;
FindLabelKeyPressed(key);
if (LabelSelected != null)
{
LabelSelected.Background = System.Windows.Media.Brushes.Yellow;
}
if (key == "F10" || key.ToLower().Contains("alt") || key.ToLower()=="left" || key.ToLower()== "right" || key.ToLower().Contains("home") || key.ToLower().Contains("win"))
e.Handled = true;
}
please give me a code.
The PrintScreen key can be detected with keyboard hooks. Call the SetWindowsHookEx API to install the WH_MOUSE_LL WH_KEYBOARD_LL hook.
You can also check whether a key is pressed using the GetKeyState API.