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

Keystrokes including ⌘ are not recognised if they don't originate in the KeyObserver #5001

Closed
oleq opened this issue Apr 5, 2018 · 2 comments
Labels
package:utils resolution:expired This issue was closed due to lack of feedback. status:stale type:bug This issue reports a buggy (incorrect) behavior.

Comments

@oleq
Copy link
Member

oleq commented Apr 5, 2018

The KeyObserver handles as Ctrl correctly. It does not matter if one pressed Ctrl+B or +B, the right thing is executed e.g. by the KeystrokeHandler. As long as the keystroke was pressed in the editing root (or descendant).

But when it comes to the listeners attached to the UI elements (e.g. link form), there's no KeyObserver underneath. And there's no discovery of the metaKey. So in the UI, Ctrl+B and +B are in fact different keystrokes.

What we need is a simple fix corresponding to the mentioned code in the KeyObserver and a couple of tests.

diff --git a/src/keyboard.js b/src/keyboard.js
index 83fde50..9652de8 100644
--- a/src/keyboard.js
+++ b/src/keyboard.js
@@ -66,6 +66,7 @@ export function getCode( key ) {
 		keyCode = key.keyCode +
 			( key.altKey ? keyCodes.alt : 0 ) +
 			( key.ctrlKey ? keyCodes.ctrl : 0 ) +
+			( key.metaKey ? keyCodes.cmd : 0 ) +
 			( key.shiftKey ? keyCodes.shift : 0 );
 	}

Discovered in ckeditor/ckeditor5-link#190 (comment).

@oleq oleq changed the title Keystrokes including ⌘ are not recognised if they don't originate in KeyObserver Keystrokes including ⌘ are not recognised if they don't originate in the KeyObserver Apr 5, 2018
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-utils Oct 9, 2019
@mlewand mlewand added this to the nice-to-have milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. package:utils labels Oct 9, 2019
@pomek pomek removed this from the nice-to-have milestone Feb 21, 2022
@CKEditorBot
Copy link
Collaborator

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

@CKEditorBot
Copy link
Collaborator

We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

@CKEditorBot CKEditorBot added the resolution:expired This issue was closed due to lack of feedback. label Nov 2, 2023
@CKEditorBot CKEditorBot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:utils resolution:expired This issue was closed due to lack of feedback. status:stale type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

4 participants