(event)
| 499 | |
| 500 | // Handles all keyboard events. |
| 501 | onKeyDownInMode(event) { |
| 502 | if (event.repeat) return; |
| 503 | |
| 504 | // NOTE(smblott) The modifier behaviour here applies only to alphabet hints. |
| 505 | if ( |
| 506 | ["Control", "Shift"].includes(event.key) && !Settings.get("filterLinkHints") && |
| 507 | [OPEN_IN_CURRENT_TAB, OPEN_WITH_QUEUE, OPEN_IN_NEW_BG_TAB, OPEN_IN_NEW_FG_TAB].includes( |
| 508 | this.mode, |
| 509 | ) |
| 510 | ) { |
| 511 | // Toggle whether to open the link in a new or current tab. |
| 512 | const previousMode = this.mode; |
| 513 | const key = event.key; |
| 514 | |
| 515 | switch (key) { |
| 516 | case "Shift": |
| 517 | this.setOpenLinkMode( |
| 518 | this.mode === OPEN_IN_CURRENT_TAB ? OPEN_IN_NEW_BG_TAB : OPEN_IN_CURRENT_TAB, |
| 519 | ); |
| 520 | break; |
| 521 | case "Control": |
| 522 | this.setOpenLinkMode( |
| 523 | this.mode === OPEN_IN_NEW_FG_TAB ? OPEN_IN_NEW_BG_TAB : OPEN_IN_NEW_FG_TAB, |
| 524 | ); |
| 525 | break; |
| 526 | } |
| 527 | |
| 528 | this.hintMode.push({ |
| 529 | keyup: (event) => { |
| 530 | if (event.key === key) { |
| 531 | handlerStack.remove(); |
| 532 | this.setOpenLinkMode(previousMode); |
| 533 | } |
| 534 | return true; // Continue bubbling the event. |
| 535 | }, |
| 536 | }); |
| 537 | } else if (KeyboardUtils.isBackspace(event)) { |
| 538 | if (this.markerMatcher.popKeyChar()) { |
| 539 | this.tabCount = 0; |
| 540 | this.updateVisibleMarkers(); |
| 541 | } else { |
| 542 | // Exit via @hintMode.exit(), so that the LinkHints.activate() "onExit" callback sees the |
| 543 | // key event and knows not to restart hints mode. |
| 544 | this.hintMode.exit(event); |
| 545 | } |
| 546 | } else if (event.key === "Enter") { |
| 547 | // Activate the active hint, if there is one. Only FilterHints uses an active hint. |
| 548 | if (this.markerMatcher.activeHintMarker) { |
| 549 | HintCoordinator.sendMessage("activateActiveHintMarker"); |
| 550 | } |
| 551 | } else if (event.key === "Tab") { |
| 552 | if (event.shiftKey) { |
| 553 | this.tabCount--; |
| 554 | } else { |
| 555 | this.tabCount++; |
| 556 | } |
| 557 | this.updateVisibleMarkers(); |
| 558 | } else if ((event.key === " ") && this.markerMatcher.shouldRotateHints(event)) { |
nothing calls this directly
no test coverage detected