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
fix(web): keyboard shortcut handling #7946
Conversation
Deploying immich with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work. Eventually would it be possible to automatically show a list of registered shortcuts when you press ?
? Like make that modal, which is currently static, dynamic?
It can be done, but it's a little tricky. You need to register all shortcuts and add some logic for filtering out duplicate and irrelevant shortcuts such as enter or escape. Hoewever, this PR should make it a lot easier to implement that. |
Yeah that makes sense. I assumed we'd have to add something like |
…web-keyboard-shortcut-handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work! Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang this is amazing! Really awesome! ❤️
Keyboard shortcuts are currently handled pretty inconsistently and maybe in an unexpected way. Let's look at an example listening for the escape key using
on:keydown={(e) => e.key === 'Escape'}
. This not only triggers when pressing escape, but also with any combination of modifier key (ctrl, alt, shift or meta). Another issue may arise when listening for a key that is entered in an input field, where the event handler will still execute.In some cases these issues are accounted for, but not everywhere. A new action
use:shortcut
and functionexecuteShortcuts
are added that manage these pitfalls. However, they aren't yet used everywhere as it would make this PR a bit large.