I'm using RawInput to deal with keystrokes. I'm finding it hard to determine if the shift is pressed together with a key.
From the RawInputStructure -> RawKeyboard, I can retrieve the key being pressed but I'm not sure how to go about things if the keys were pressed at the same time.
RI.Data.keyboard.VKey
(gets the keycode)
I'm trying to separate the Shift for each user/keyboard because at the moment when one user/keyboard shifts all of them do, same with Capslock. Simultaneous typing gets really messy.
How can I know if the shift is pressed together with another key? Am I looking for it in the right structure or should I look elsewhere?
There's no such thing as two keys being "pressed at the same time." One goes down, and then the other. You should get notified of each one separately. When the shift key is pressed or released, set or clear a flag in your program to remember its current state.
That's in fact what the OS already does for ordinary keyboard input. It keeps a key-state map and updates it with each keyboard message. Use GetKeyState
to check a key's state as of the most recent message to be processed, or use GetAsyncKeyState
to check the key's state at the moment you call the function. (The two might be different if the keyboard state has changed but you haven't processed those keyboard messages yet, such as if the user is typing faster than your program can handle.)
You can try this method:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With