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

Feature request: add key names from web tool #869

Closed
jtroo opened this issue Mar 24, 2024 · 9 comments · Fixed by #870
Closed

Feature request: add key names from web tool #869

jtroo opened this issue Mar 24, 2024 · 9 comments · Fixed by #870
Labels
enhancement New feature or request

Comments

@jtroo
Copy link
Owner

jtroo commented Mar 24, 2024

Is your feature request related to a problem? Please describe.

https://github.com/houmain/keymapper?tab=readme-ov-file#key-names

Apparently there's a website to allow easy discovery of keycodes. Not having tested yet, I would assume this works well for LLHOOK but I am less certain about Linux evdev and Interception.

But it would be able to use/suggest in docs if it works

Describe the solution you'd like.

Investigate and see if it works

Describe alternatives you've considered.

Not adding them because it doesn't work as intended

Additional context

No response

@jtroo jtroo added the enhancement New feature or request label Mar 24, 2024
@rszyma
Copy link
Contributor

rszyma commented Mar 24, 2024

Not having tested yet, I would assume this works well for LLHOOK but I am less certain about Linux evdev and Interception.

on Linux (wayland) and US layout detects all keyboard keys, but no mouse keys/events

@rszyma
Copy link
Contributor

rszyma commented Mar 24, 2024

Though what would it the codes be used for? arbitrary-code? Then it shows different values on Linux e.g. the tool shows 65 for 'a' key, but evtest shows 30.

@jtroo
Copy link
Owner Author

jtroo commented Mar 24, 2024

It would be used for str_to_oscode

@jtroo
Copy link
Owner Author

jtroo commented Mar 24, 2024

Interesting, so the event.code field represents the underlying code that was pressed before OS desktop-level remapping. E.g. changing OS layout to dvorak does not change the code field, but does change the key field. This is consistent between Windows and Linux.

But what kanata Win-LLHOOK does today is use the equivalent of event.key in the hook function. So changing to use the equivalent of event.code by default would be a breaking change. It does seem more correct to change to that behaviour though, which is what keymapper appears to do.

@jtroo
Copy link
Owner Author

jtroo commented Mar 24, 2024

I would guess switching to use scancodes should also fix this long-standing issue that I hadn't considered before.

#152

Probably worth doing! 🙂

@jtroo jtroo linked a pull request Mar 25, 2024 that will close this issue
4 tasks
@jtroo jtroo reopened this Mar 25, 2024
@jtroo
Copy link
Owner Author

jtroo commented Mar 25, 2024

As it turns out, unsafe { dbg!(MapVirtualKeyA(lparam.scanCode, 1)) } maps to the VK of the current layout. Not working just yet.. instead of calling this function, need to convert to the US layout.

@wis
Copy link
Contributor

wis commented Mar 25, 2024

Do you still need the key names? I looked up the w3c spec for KeyboardEvent which is the object type in the browser for all the keyboard events, and found a list of them.

quote from the UIEvents w3c spec document:

the complete set of key and code values defined in [UIEvents-Key] and [UIEvents-Code] (subject to platform availability)

The UIEvents-Code link in the quote links to a footnote reference at the bottom, which contains a link to another spec document: UI Events KeyboardEvent code Values, which contains tables that list all the key names.

More on event.code: KeyboardEvent.code - MDN

@jtroo
Copy link
Owner Author

jtroo commented Mar 25, 2024

As it turns out, unsafe { dbg!(MapVirtualKeyA(lparam.scanCode, 1)) } maps to the VK of the current layout. Not working just yet.. instead of calling this function, need to convert to the US layout.

Fixed in #871

Now still need to add the proper docs and add to str_to_oscode

@jtroo jtroo closed this as completed Mar 26, 2024
@gerhard-h
Copy link
Contributor

BREAKING CHANGE: Add web event.code names as usable configuration key names, making them no longer usable in deflocalkeys.

I tested the feature and used successfully Numpad9, F1 (upper case) in my config - great.

Then I tried to break it
(deflocalkeys-wintercept ^ 192
(deflocalkeys-wintercept £ 186
(deflocalkeys-wintercept Lang1 186

But they all worked. :)

(deflocalkeys-wintercept ⇞ finally didn't work, but I think it is not related to this feature.

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

Successfully merging a pull request may close this issue.

4 participants