Check only the specified key
I can check if a key is pressed Keyboard.IsKeyDown
. But how can I check the specified key, it is only the key not working?
+3
SiberianGuy
source
to share
4 answers
There is a way to get the current state of the keyboard and determine what keys are pressed, but it's a bit messy and uses user32.dll. Look at the answer to this question.
fooobar.com/questions/510323 / ...
+1
Ben
source
to share
depending on which key you want to check, do something like this
if(Keyboard.IsKeyDown(Key.LeftCtrl))
//do something
0
The angry saxon
source
to share
Or if you only want to do something if you press that key, try something like
if(!Keyboard.IsKeyDown(Key.LeftCtrl)) return;
This will kick them out of the function if no key is pressed.
0
The angry saxon
source
to share
Perhaps you can count the number of KeyDown and KeyUp? If the counter is 1 and this is the key you want ....
0
mlemay
source
to share