-
Notifications
You must be signed in to change notification settings - Fork 85
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
AF-155: Improved Hotkeys #106
Conversation
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.
Looks great and works great. Noticed one issue with key binding for Cmd+N and a couple minor comments.
@mikecarenzo As you merge the hotkeys from the search branch, I wanted to highlight this comment from PR #99:
|
SonarCloud Quality Gate failed. 1 Bug No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@mehaase I'd like to stick to the Operating System's conventions as closely as possible. On MacOS I changed the "Grid" shortcut to |
The MacOS shortcuts look great! Thanks for picking up on that detail. |
Overview
Improves hotkey stability and separates settings for Windows/Linux and MacOS.
Improved Hotkey Stability
This PR introduces a set of stability enhancements to the
HotkeyObserver
. Originally, theHotkeyObserver
tracked the current state of the keyboard by monitoringkeydown
andkeyup
events. In effect:keydown
event adds a key to the key state.keyup
event removes a key from the key state.Unfortunately, there are cases where a
keydown
event DOES NOT trigger an associatedkeyup
event. For instance:keyup
event.keyup
event.keyup
events are ignored.As a result, the
HotkeyObserver
is occasionally led to believe that certain keys are still being held down even when the user's hands are off the keyboard. What's worse, if the user tries another hotkey combination, the pressed keys will be added to an already incorrect key state, the corrupted key state will fail to match any registered hotkeys, and nothing happens.The initial implementation of
HotkeyObserver
attempted to account for thiskeyup
quirk. However, the list of reasonskeyup
doesn't fire has grown to a point where it no longer makes sense to rely on it.Now, the keyboard state is assessed using everything that can be gleaned from a single
KeyboardEvent
(raised bykeydown
). This includes the currently pressed key and any associated modifier keys (Control, Alt, Shift, and Meta). While this limits possible hotkey sequences, it does remove the need to track the current key state acrosskeydown
andkeyup
events.Separate Hotkey Settings for Windows/Linux and MacOS
This PR replaces
settings.json
withsettings_win.json
andsettings_macos.json
. Both.json
enumerate the same list of settings (with different values) and allow the application to be configured dynamically depending on the device's current operating system. This new feature has been used to add support for MacOS style hotkeys.