Prevented handling shortcuts with meta/ctrl key

This commit is contained in:
Eugene 2023-07-24 17:16:51 +03:00
parent e7fc5f5614
commit 4fc0ca17b6
2 changed files with 8 additions and 5 deletions

View File

@ -38,6 +38,7 @@ export class Editor {
this.element.addEventListener('keydown', this.handleKeydown)
this.element.value = cell.value
this.element.focus()
this.element.select()
}
handleKeydown = (event: KeyboardEvent) => {

View File

@ -70,6 +70,7 @@ export class Scroller {
}
private handleKeydown = (event: KeyboardEvent) => {
console.log(event)
//* Navigation
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
event.preventDefault()
@ -106,12 +107,13 @@ export class Scroller {
}
}
}
if (!event.metaKey && !event.ctrlKey) { //* Prevent handle shortcutrs
if (event.key === 'F2' || /^([a-z]|[а-я])$/.test(event.key.toLowerCase())) { //* English and Russian keyboard. Or F2 button
event.preventDefault()
if (!this.root.selection.selectedCell) return;
this.root.showEditor(this.root.selection.selectedCell)
}
}
if (event.key === 'Delete') {
event.preventDefault()