make sure keyboard shortcuts are only for the svg-editor body
parent
4f051fc355
commit
ed1c71683c
|
@ -5821,8 +5821,13 @@ editor.init = function () {
|
||||||
});
|
});
|
||||||
// register the keydown event
|
// register the keydown event
|
||||||
document.addEventListener('keydown', (e) => {
|
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()}`;
|
const key = `${(e.metaKey) ? 'meta+' : ''}${(e.ctrlKey) ? 'ctrl+' : ''}${e.key.toLowerCase()}`;
|
||||||
|
// return if no shortcut defined for this key
|
||||||
if (!keyHandler[key]) return;
|
if (!keyHandler[key]) return;
|
||||||
|
// launch associated handler and preventDefault if necessary
|
||||||
keyHandler[key].fn();
|
keyHandler[key].fn();
|
||||||
if (keyHandler[key].pd) {
|
if (keyHandler[key].pd) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
Loading…
Reference in New Issue