frontend
frontend copied to clipboard
Fix shortcuts for non-qwerty keyboard layouts (revert #12892)
Proposed change
After https://github.com/home-assistant/frontend/pull/12892 was merged, shortcuts did NOT work anymore on non-qwerty keyboards. It was working fine before.
I'm using Bépo and the issue appeared ~ last week on all my devices (Windows, Linux). After some investigation and testing, I discovered this pull request that actually broke what it was claiming to fix.
Type of change
- [ ] Dependency upgrade
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (thank you!)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
The documentation of tinykeys, the library used, specifies (https://github.com/jamiebuilds/tinykeys):
// Matches `event.key`: "d" // Matches: `event.code`: "KeyD"
And you can check here that:
- KeyboardEvent.code returns a string with the code value of the physical key represented by the event.
- KeyboardEvent.key returns the value of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout.
Checklist
- [x] The code change is tested and works locally.
- [x] There is no commented out code in this PR.
- [x] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
@yosilevy could you please confirm what @Salamandar claims?
FYI @bramkragten the same issue was fixed in an unrelated project : https://github.com/cinnyapp/cinny/issues/680#event-7136037835 (my issue too)