Skip to content

Commit

Permalink
[#229][Xooxle] Respond to keydown, not keyup.
Browse files Browse the repository at this point in the history
This has the side effect that long presses result in the event being
registered repeatedly.
  • Loading branch information
pishoyg committed Nov 1, 2024
1 parent 1fe7075 commit 6f7e309
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions site/crum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ function main() {

// NOTE: This is where we define all our command shortcuts. It's important for
// the content to remain in sync with the help panel.
// TODO: (#280) Combine the help panel and `keyup` listener code.
document.addEventListener('keyup', (e: KeyboardEvent) => {
// TODO: (#280) Combine the help panel and `keydown` listener code.
document.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.metaKey || e.ctrlKey || e.altKey) {
// If the user is holding down a modifier key, we don't want to do
// anything.
Expand Down
4 changes: 3 additions & 1 deletion site/xooxle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,11 @@ function handleSearchQuery(timeout: number) {
}

searchBox.addEventListener('input', () => { handleSearchQuery(100); });
// Prevent other elements in the page from picking up a `keyup` event on the
// Prevent other elements in the page from picking up key events on the
// search box.
searchBox.addEventListener('keyup', (event: KeyboardEvent) => { event.stopPropagation(); });
searchBox.addEventListener('keydown', (event: KeyboardEvent) => { event.stopPropagation(); });
searchBox.addEventListener('keypress', (event: KeyboardEvent) => { event.stopPropagation(); });
fullWordCheckbox.addEventListener('click', () => { handleSearchQuery(0); });
regexCheckbox.addEventListener('click', () => { handleSearchQuery(0); });

Expand Down

0 comments on commit 6f7e309

Please sign in to comment.