Skip to content

Commit

Permalink
Prevent default on backspace keys to disable navigation actions (#286)
Browse files Browse the repository at this point in the history
* Audit dependencies, bump vulnerabilities, remove yarn.lock

* Attempt to prevent navigation back actions
  • Loading branch information
lewish authored Feb 23, 2024
1 parent cc4c130 commit cf791de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class Controller {
}

handleKeyPress(event: KeyboardEvent) {
if (event.keyCode == 8) {
// Disable navigation back action on backspace.
event.preventDefault();
}
if (!event.ctrlKey && !event.metaKey && event.keyCode !== 13) {
store.currentTool.handleKey(
String.fromCharCode(event.keyCode),
Expand Down Expand Up @@ -110,6 +114,8 @@ export class Controller {

if (event.keyCode === 8) {
specialKeyCode = constants.KEY_BACKSPACE;
// Disable navigation back action on backspace.
event.preventDefault();
}
if (event.keyCode === 46) {
specialKeyCode = constants.KEY_DELETE;
Expand Down

0 comments on commit cf791de

Please sign in to comment.