#GetASyncKeyState

6 messages · Page 1 of 1 (latest)

grim moth
#

Basically when I get a key state of a key that is being held down it is giving me -32786 which is correct but when its still pressed down and another key is pressed it sets it back to 0

Example to make this easier:

Space key is down -> GetAsyncKeyState(VK_SPACE) = -32768 -> pressed CTRL while space is still down -> GetAsyncKeyState(VK_SPACE) = 0 even though its still pressed.

So what I'm trying to keep the value as it is as the keystate of Space is still down

odd basaltBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

hushed wharf
#

I think you should SetWindowsHookEx for capture keyboard events.

surreal ledge
#

I am uncertain, but I believe what may be happening is that Windows is converting the key combination to a modifier combination key CTRL+SPACE which it treats as a different virtual key

hushed wharf
#

hook is more easier and isn't missing keyboards.

surreal ledge
#

I suspect it could be done by tracking keydown and key up events for the modifier keys (ctrl, alt, shift) and one other key as I am pretty sure you can only have 4 keys pressed at a time and be detected. Here I press ctrl/alt/shift/space and then release them in some random order:

keydown  keyCode=17        which=17        charCode=0        
         shiftKey=false ctrlKey=true  altKey=false metaKey=false
keydown  keyCode=18        which=18        charCode=0        
         shiftKey=false ctrlKey=true  altKey=true  metaKey=false
keydown  keyCode=16        which=16        charCode=0        
         shiftKey=true  ctrlKey=true  altKey=true  metaKey=false
keydown  keyCode=32  ( )   which=32  ( )   charCode=0        
         shiftKey=true  ctrlKey=true  altKey=true  metaKey=false
keyup    keyCode=32  ( )   which=32  ( )   charCode=0        
         shiftKey=true  ctrlKey=true  altKey=true  metaKey=false
keyup    keyCode=16        which=16        charCode=0        
         shiftKey=false ctrlKey=true  altKey=true  metaKey=false
keyup    keyCode=17        which=17        charCode=0        
         shiftKey=false ctrlKey=false altKey=true  metaKey=false
keyup    keyCode=18        which=18        charCode=0        
         shiftKey=false ctrlKey=false altKey=false metaKey=false

You can play with this tool at https://unixpapa.com/js/testkey.html