make sure keyboard shortcuts are only for the svg-editor body

master
JFH 2020-07-11 16:37:54 +02:00
parent 4f051fc355
commit ed1c71683c
1 changed files with 5 additions and 0 deletions

View File

@ -5821,8 +5821,13 @@ editor.init = function () {
});
// register the keydown event
document.addEventListener('keydown', (e) => {
// only track keyboard shortcuts for the body containing the SVG-Editor
if (e.target.nodeName !== 'BODY') return;
// normalize key
const key = `${(e.metaKey) ? 'meta+' : ''}${(e.ctrlKey) ? 'ctrl+' : ''}${e.key.toLowerCase()}`;
// return if no shortcut defined for this key
if (!keyHandler[key]) return;
// launch associated handler and preventDefault if necessary
keyHandler[key].fn();
if (keyHandler[key].pd) {
e.preventDefault();