views:

169

answers:

1

I have a text editor on my site and I want users to be able to use keyboard shortcuts to save, just like they would in Microsoft Word.

For the Mac: Command + S For the PC: Control + S

What is the best way to accomplish this in JQUERY? Also, this will be used to save content in CKEDITOR, which uses an iFrame, not sure if that's an issue or not.

Thanks

A: 

You are aware that CKEditor has built in hotkey functionality?

It's pretty straightforward to implement: You set up an array keystrokes in your config array; take the example array from the link above; Look up the keystroke for "S"; and amend the array by an entry for it, and the appropriate CKEditor command. I can't test it right now but this is what it should look like. You may need to look up the appropriate command for the "save" operation you want to execute.

... your config array .....

"keystrokes": 
[
    [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
    [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],

    [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],

    [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],
    [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],
    [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],

    [ CKEDITOR.CTRL + 76 /*L*/, 'link' ],

    [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ],
    [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],
    [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ],

    [ CKEDITOR.CTRL + 83 /*S*/, 'save' ],

    [ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ]
];
Pekka
Yes, but there is not documentation on how to implement it?
AnApprentice
See my edited answer.
Pekka