Skip to content

Instantly share code, notes, and snippets.

@skflowne
Last active August 4, 2020 23:57
Show Gist options
  • Select an option

  • Save skflowne/8760587ffb447126f44b37e23f7fb023 to your computer and use it in GitHub Desktop.

Select an option

Save skflowne/8760587ffb447126f44b37e23f7fb023 to your computer and use it in GitHub Desktop.
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "ArrowDown") {
fileIndex.update((i) => (i + 1) % $fileSearchResults.length)
}
if (e.key === "ArrowUp") {
fileIndex.update((i) => (i - 1 < 0 ? $fileSearchResults.length - 1 : i - 1))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment