Skip to content

Commit

Permalink
Improve behaviour of arrow keys when focused on search input
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincollins committed Jan 29, 2023
1 parent d611f09 commit 66b7714
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/client/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import '../css/main.css'

const handleKeyPress = (event) => {
const element = document.activeElement.tagName

// Check for focus on input elements
if (element.toLowerCase() === 'input') {
// If ESC is pressed, then remove focus from input
if (event.key === 'Escape') document.body.click()

// If UP or DOWN arrow is pressed then remove focus
if (['ArrowUp', 'ArrowDown'].includes(event.key)) document.body.click()

return
}

Expand Down

0 comments on commit 66b7714

Please sign in to comment.