Opened 6 years ago

Last modified 6 years ago

#14799 confirmed New Feature

Handling MOD+(i,b,u) shortcuts in more friendly way to hostile environment

Reported by: Michal Aichinger Owned by:
Priority: Normal Milestone:
Component: Accessibility Version: 4.0
Keywords: Cc:


Steps to reproduce

Our application is setting shortcuts Ctrl+Alt+i in Windows and Ctrl+Cmd+i in Mac version and they works fine until editor is focused.

We are checking exactly which modifier keys are used and act only when exact combination is pressed. We find out that editor is handling Ctrl+Cmd+i shortcut and stopping event propagation. What a nasty boy!

I digged into source code and find method getKeystroke, which do:

if (this.$.ctrlKey || this.$.metaKey)  a += CKEDITOR.CTRL;

So you can make text italic with: Ctrl+i, Win+i, Cmd+i, Ctrl+Win+i, Ctrl+Cmd+i! This is not mentioned in documentation, where is explicitly mentioned Ctrl+i.

Expected result

I expect that editor will distinguish Ctrl and Meta key and do what is in documentation -> handle only Ctrl+letter shortcuts. If you want to support also meta key, please, to it in smarter way, that both shouldn't be pressed:

if ((this.$.ctrlKey || this.$.metaKey) && !(this.$.ctrlKey && this.$.metaKey))  a += CKEDITOR.CTRL;

Actually there should be some configuration option to set behavior for this method.

And last comment. What about to do not stop event propagation ( and just prevent events defaults?

Actual result

Other details (browser, OS, CKEditor version, installed plugins)

Used version:"4.5.4 (Standard)",revision:"d4677a3".

Change History (1)

comment:1 Changed 6 years ago by Jakub Ś

Keywords: shortcuts removed
Status: newconfirmed

We are using both to support Mac and Windows/Linux. On Win Ctrl+A will do the same as Cmd+A for Mac. It is rather intuitive but perhaps we might mention this in docs. What do you think team?

Editor supports buch of keystrokes so when keystroke originates from CKEditor it makes a lot of sense to stopProagation upwards. I however agree that we could write the condition like that

if ((this.$.ctrlKey || this.$.metaKey) && !(this.$.ctrlKey && this.$.metaKey))

to be more friendly towards custom solutions like yours.

NOTE: From what I have checked we are using stopPropagation and preventDefault methods in event.js. The stopPropagation is only used in dialogs for keyPress handler. The preventDefault is used in many places but it also contains extra parameter which if true also sets stopPropagation. We use data.preventDefault( true ); in keystrokehandler and six plugins.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy