InputBot icon indicating copy to clipboard operation
InputBot copied to clipboard

block_bind conflicts with is_pressed()

Open SonicZentropy opened this issue 1 year ago • 3 comments

I've been tinkering trying to get this to work for a while, and I can't find a good approach. I'm wanting a way to block_bind a particular key, but still have the is_pressed() method recognize the key is held down "in real life" even though it isn't being propagated onward.

// Do not propagate the Capslock key onward at all
CapsLockKey.block_bind(|| ()); 

LKey.bind(|| {
        //This check will always return false due to the block_bind
        if CapsLockKey.is_pressed() { }
});

The only way I've managed to get it working is to create a second "fake" keyboard and selectively emit synthetic keyboard events on it, then not emit ANY events on the main keyboard. Is there a cleaner way?

SonicZentropy avatar Nov 05 '22 10:11 SonicZentropy

@SonicZentropy I guess there is no cleaner way right now. One option could be to have InputBot track the keystate internally for blockable binds.

obv-mikhail avatar Nov 24 '22 21:11 obv-mikhail

I think this is the problem

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644985(v=vs.85)

Note When this callback function is called in response to a change in the state of a key, the callback function is called before the asynchronous state of the key is updated. Consequently, the asynchronous state of the key cannot be determined by calling GetAsyncKeyState from within the callback function.

NiiightmareXD avatar Sep 19 '23 14:09 NiiightmareXD

Is there been a update about this?

jaspersmitNL avatar Feb 25 '24 10:02 jaspersmitNL