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

get NumLock status #1426

Open
jice-nospam opened this issue Jan 31, 2020 · 5 comments
Open

get NumLock status #1426

jice-nospam opened this issue Jan 31, 2020 · 5 comments
Labels
F - question There's no such thing as a stupid one S - api Design and usability

Comments

@jice-nospam
Copy link

Right now, we can detect key press on the numlock key, but is there a way to check the status (on/off) of the numlock ?

@jice-nospam
Copy link
Author

In fact this might be a bug because we get both ArrowLeft KeyboardInput event and '4' ReceivedCharacter event when we press the numpad 4 key whereas it should be one or another depending on the numlock status

@ArturKovacs
Copy link
Contributor

The original description and the comment following it describe distinct issues.

The first one will require the addition of a new API which can query the status of the numlock key. This overlaps with #1010

The second one is going to be resolved by #753

@Plecra
Copy link

Plecra commented Dec 19, 2023

I'd like to expand this feature request to resolve khonsulabs/cushy#81. The ModifiersState that we can receive in ModifiersChanged doesn't allow us to read the NumLock or CapsLock states. This doesn't overlap with issue 1010 as an event-based API is still useful even before we have an api to mirror getkey, and it wasn't resolved by #753, though I'm not sure why.

Each KeyboardEvent implementation tracks numlock and capslock. Here's where they're read in linux:

self.caps_lock = mod_name_is_active(ffi::XKB_MOD_NAME_CAPS);
self.logo = mod_name_is_active(ffi::XKB_MOD_NAME_LOGO);
self.num_lock = mod_name_is_active(ffi::XKB_MOD_NAME_NUM);

(and here in windows)
but those aren't forwarded to the public ModifiersState

let mut to_mods = crate::keyboard::ModifiersState::empty();

@kchibisov
Copy link
Member

@Plecra fill free to extend the event if they are reliably observable on platforms.

@danielhjacobs
Copy link

danielhjacobs commented May 16, 2024

Also wondering the same for Caps Lock and Scroll Lock. It would add a way to fix ruffle-rs/ruffle#13513 (comment)

The JavaScript way to do this is with https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState / https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/getModifierState

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F - question There's no such thing as a stupid one S - api Design and usability
Development

No branches or pull requests

6 participants