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

Numeric Keypad Support Suggestion #4898

Open
Nathaniel-Wu opened this issue Apr 27, 2024 · 1 comment
Open

Numeric Keypad Support Suggestion #4898

Nathaniel-Wu opened this issue Apr 27, 2024 · 1 comment

Comments

@Nathaniel-Wu
Copy link

What you want IINA to do:
In input config, fuzzily distinguish numpad keys from their corresponding number row keys. More specifically, if the input config only sets a binding for one of them, use both to do the same thing; however, if there are different bindings for both, distinguish the keys. For example: if the user sets the number row key "1" to do "A", and doesn't set a binding for the numpad key "KP1", pressing either key will do "A"; or if the user sets the numpad key "KP1" to do "B", and doesn't set a binding for the number row key "1", pressing either key will do "B"; however, if the number row key "1" to do "A", and the numpad key "KP1" is set to do "B", pressing the two keys will do different things.

What IINA does currently:
Currently, IINA key mapping only supports number row keys 0 - 9. Setting key binding with the in-app key mapping feature will save numpad keys as number row keys instead. Editing the config file manually to set bings with numpad keys KP0 - KP9 will not work, the binds do show up in the IINA key binding settings, but as 0 - 9, and the app doesn't actually respond to them; if bindings for number row keys 0 - 9 have been set, pressing KP0 - KP9 will work the same as those instead.

Why you think this should be added:
To have more keys to use. And it won't affect existing input config files generated through IINA.

Examples of other projects that have something similar:
mpv fully supports numpad keys, but it distinguishes them from number row keys strictly, not interchangeable even if only one kind of them is set.

@svobs
Copy link
Contributor

svobs commented May 11, 2024

This is a good idea on the surface. But implementing this runs into trouble when trying to integrate key bindings with MacOS's menu bar, which IINA does for lots of key bindings.

Going off into the weeds...

I did find it's easy to distinguish between the number pad and the number row (as I'll refer to them) when using the keyDown API from NSEvent, as there is a special flag NSEvent.ModifierFlags.numericPad which is set for the former to distinguish it from the latter. And you can bind global shortcuts in System Settings > ... > Keyboard Shortcuts which work as desired (I tried this and found that it works), it's a little strange. The UI provides no clue that 1 is a number pad char -- the strings for both bindings look exactly the same!

But menu item "key equivalents" are a different mechanism still. The public API for NSMenuItem provides only keyEquivalentModifierMask (which ignores the numericPad flag) and keyEquivalent which is a string. Perhaps there are some magic strings for the number pad chars? I couldn't find anything. I did find this old link which describes an awkward workaround which seems like more of a last resort.

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

No branches or pull requests

3 participants