mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-01 16:22:32 +00:00
avoid capturing keyboard events when focusing input or navigation elements, closes #1
This commit is contained in:
@@ -459,6 +459,18 @@
|
|||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
on:keydown={(e) => {
|
on:keydown={(e) => {
|
||||||
|
console.log(e);
|
||||||
|
let targetInput =
|
||||||
|
e.target.tagName === 'INPUT' ||
|
||||||
|
e.target.tagName === 'TEXTAREA' ||
|
||||||
|
e.target.tagName === 'SELECT' ||
|
||||||
|
e.target.role === 'combobox' ||
|
||||||
|
e.target.role === 'radio' ||
|
||||||
|
e.target.role === 'menu' ||
|
||||||
|
e.target.role === 'menuitem' ||
|
||||||
|
e.target.role === 'menuitemradio' ||
|
||||||
|
e.target.role === 'menuitemcheckbox';
|
||||||
|
|
||||||
if (e.key === '+' && (e.metaKey || e.ctrlKey)) {
|
if (e.key === '+' && (e.metaKey || e.ctrlKey)) {
|
||||||
createFile();
|
createFile();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -469,13 +481,17 @@
|
|||||||
dbUtils.duplicateSelection();
|
dbUtils.duplicateSelection();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
|
} else if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
|
||||||
copySelection();
|
if (!targetInput) {
|
||||||
e.preventDefault();
|
copySelection();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
} else if (e.key === 'x' && (e.metaKey || e.ctrlKey)) {
|
} else if (e.key === 'x' && (e.metaKey || e.ctrlKey)) {
|
||||||
cutSelection();
|
if (!targetInput) {
|
||||||
e.preventDefault();
|
cutSelection();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
} else if (e.key === 'v' && (e.metaKey || e.ctrlKey)) {
|
} else if (e.key === 'v' && (e.metaKey || e.ctrlKey)) {
|
||||||
if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') {
|
if (!targetInput) {
|
||||||
pasteSelection();
|
pasteSelection();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -502,8 +518,10 @@
|
|||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if (e.key === 'a' && (e.metaKey || e.ctrlKey)) {
|
} else if (e.key === 'a' && (e.metaKey || e.ctrlKey)) {
|
||||||
selectAll();
|
if (!targetInput) {
|
||||||
e.preventDefault();
|
selectAll();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
} else if (e.key === 'p' && (e.metaKey || e.ctrlKey)) {
|
} else if (e.key === 'p' && (e.metaKey || e.ctrlKey)) {
|
||||||
$elevationProfile = !$elevationProfile;
|
$elevationProfile = !$elevationProfile;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -531,8 +549,10 @@
|
|||||||
e.key === 'ArrowLeft' ||
|
e.key === 'ArrowLeft' ||
|
||||||
e.key === 'ArrowUp'
|
e.key === 'ArrowUp'
|
||||||
) {
|
) {
|
||||||
updateSelectionFromKey(e.key === 'ArrowRight' || e.key === 'ArrowDown', e.shiftKey);
|
if (!targetInput) {
|
||||||
e.preventDefault();
|
updateSelectionFromKey(e.key === 'ArrowRight' || e.key === 'ArrowDown', e.shiftKey);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:dragover={(e) => e.preventDefault()}
|
on:dragover={(e) => e.preventDefault()}
|
||||||
|
Reference in New Issue
Block a user