Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block_bind conflicts with is_pressed() #69

Open
SonicZentropy opened this issue Nov 5, 2022 · 3 comments
Open

block_bind conflicts with is_pressed() #69

SonicZentropy opened this issue Nov 5, 2022 · 3 comments

Comments

@SonicZentropy
Copy link
Contributor

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?

@obv-mikhail
Copy link
Owner

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

@NiiightmareXD
Copy link
Contributor

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.

@jaspersmitNL
Copy link

Is there been a update about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants