Reputation: 23
I have a project using codeigniter. There have a option to open modal using shortcut key. Like, when I click 'n' then open Note modal. But if any input or textarea is focused then don't work the shortcut key. Now I'm useing summernote (rich text editor). But now this setting isn't working.
For knowing input or textarea is focused, I'm used this code:
var activeElement = document.activeElement.tagName;
if (activeElement !== "INPUT" && activeElement !== "TEXTAREA"){
//working shortcut key
}
But how I know that any summernote (rich text editor) is focused?
Upvotes: 0
Views: 577
Reputation: 325
your editor is using a contentEditable div
. The className of the summernote div
is always note-editable
.
So you can try :
if (document.activeElement.className === 'note-editable') {
// summernote editor is focused
}
Upvotes: 1