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

fix: shortcuts with Option key #31

Merged
merged 3 commits into from
Jan 6, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/routes/Settings/lib/controls/ShortcutControl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
async function recordShortcut() {
shortcutArray = [];
hotkeys.unbind();
// Prevent closing Preferences when recording already registered shortcut
unregister(preferences.get("shortcut"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would be an issue with this though...

For eg:

if I try executing setting CMD + Space which already is assigned to spotlight. When I click on the recorder, It will unregister the old shortcut but when I press CMD + Space spotlight would be opened. And hence there won't be a new registered shortcut & the previous shortcut would also be unregistered.

Leaving us with no shortcut to start the app 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ParthJadhav, I have the same issue on current master 🥲

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is in hotkeys-js: it cannot capture last key of system hotkeys sequence

Screen.Recording.2023-01-06.at.21.14.36.mp4

So maybe we put this problem into another issue? Or you prefer resolve it in this PR? 🙂

hotkeys("*", { keyup: true }, function (event) {
if (event.type === "keydown") {
if (shortcutArray.length < 3) {
Expand All @@ -49,11 +51,10 @@
}
} else {
if (!modifiers.includes(event.key)) {
if (event.key === " "){
shortcutArray.push("Space");
} else {
shortcutArray.push(event.key);
}
const key = event.code.startsWith("Key")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ParthJadhav, check this please

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it..

? event.code.substring(3)
: event.code;
shortcutArray.push(key);
updateShortcutPreference(shortcutArray);
hotkeys.unbind();
} else {
Expand Down