-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce Feature for Keyboard Shortcuts #7442
Conversation
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
9276d2b
to
bbfb7c9
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
const toBindingWithDefaults = (binding: Binding) => | ||
isString(binding) | ||
? { code: binding, shift: false, ctrl: false, altOrOption: false, meta: false } | ||
: { ctrl: false, shift: false, altOrOption: false, meta: false, ...binding }; |
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.
Why not just have the param be SetRequired<Partial<Binding>, "code">
?
Furthermore, should do some checks here concerning trying to make sure someone doesn't do Ctrl+KeyK
as the code
field?
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.
Furthermore, should do some checks here concerning trying to make sure someone doesn't do Ctrl+KeyK as the code field?
We don't have to worry about it. Modifiers trigger their own event in the listener, which means that technically you can't say that the code is Ctrl+KeyK
because that doesn't exist. However, if you wish, you are able to add keybinding to e.g. ControlLeft
. But, I don't see that as a big deal, because that would be just developer doing weird stuff.
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.
Why not just have the param be SetRequired<Partial, "code">?
I don't understand the question here.
packages/business-features/keyboard-shortcuts/src/invoke-shortcut.injectable.ts
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
… listener to be used in the application Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
bbfb7c9
to
926e7e2
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Motivation:
New keyboard shortcuts can be introduced by any Feature simply by registering implementation for
keyboardShortcutInjectionToken
Example:
Given injectable being registered, anywhere in the application where you press
Ctrl + K
, you will see theconsole.log
.The Feature also introduces something called
KeyboardShortcutScope
which is a React Component, which you can use to wrap your component to make keyboard shortcuts only work in that scope.Example: