Main navigation
Product navigation
Main content
CKEditor 4
Overview
Demo
Accessibility Checker
Add-ons
Documentation
Download
Pricing
More
Home
WYSIWYG Editors
CKEditor 4
CKEditor 5
Image upload
CKFinder
Easy Image
Collaboration
Comments
New
Track changes
New
Collaborative editing
Pricing
Case studies
New
Documentation
Help center
Blog
Contact us
The forum operates in
read-only
mode. Please head to
StackOverflow
for support.
Forums
CKEditor
CKEditor
Last post
Wed, 11/11/2009 - 14:46
#1
a_shyam41
Joined:
09/11/2009
Posts:
30
Hotkey for custom button
What is the property that can be used to provide hotkey to a custom button added through custom plugins?
Thu, 11/12/2009 - 10:22
#2
a_shyam41
Joined:
09/11/2009
Posts:
30
Re: shortcut key for custom button
any ideas?
Thu, 11/12/2009 - 11:59
#3
a_shyam41
Joined:
09/11/2009
Posts:
30
Re: Hotkey for custom button
As usual, I have found the solution myself, which might help somebody.
Basically, I attached a keydown event to the iframe created by ckeditor:
iframes = document.getElementsByTagName("iframe");
iframes[0].contentWindow.document.body.attachEvent("onkeydown", catchKeyDown);
then I have to write the javascript function catchKeyDown which handles keydown event of the iframe in the outer aspx page.
var key = 0;
function catchKeyDown (e) {
if (e.keyCode == 17) {
key++;
}
if (e.keyCode == 83 && key == 1) {
key++;
}
if (e.keyCode != 17 && e.keyCode != 83) {
key = 0;
}
if (key == 2) {
key = 0;
CKEDITOR.instances.editor1.execCommand('searcher');
}
}
This sample traps CTRL+S key stroke and when it finds it, it executes the command defined for that custom button.
Twitter
Facebook
Facebook
Instagram
Medium
Linkedin
GitHub
Arrow down
Phone
Menu
Close icon
Check
Re: shortcut key for custom button
Re: Hotkey for custom button
Basically, I attached a keydown event to the iframe created by ckeditor:
iframes = document.getElementsByTagName("iframe");
iframes[0].contentWindow.document.body.attachEvent("onkeydown", catchKeyDown);
then I have to write the javascript function catchKeyDown which handles keydown event of the iframe in the outer aspx page.
var key = 0;
function catchKeyDown (e) {
if (e.keyCode == 17) {
key++;
}
if (e.keyCode == 83 && key == 1) {
key++;
}
if (e.keyCode != 17 && e.keyCode != 83) {
key = 0;
}
if (key == 2) {
key = 0;
CKEDITOR.instances.editor1.execCommand('searcher');
}
}
This sample traps CTRL+S key stroke and when it finds it, it executes the command defined for that custom button.