components/switcher-form: listen to keydown events instead of keyup

This reduces perceived input delay and allows key repeat to occur.

Co-authored-by: handlerug <handlerug@handlerug.me>
Co-committed-by: handlerug <handlerug@handlerug.me>
This commit is contained in:
handlerug
2025-11-25 16:41:53 +01:00
committed by Simon Ser
parent 1e630aed0d
commit 910ce284a2

View File

@@ -65,7 +65,7 @@ export default class SwitcherForm extends Component {
this.handleInput = this.handleInput.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleKeyUp = this.handleKeyUp.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this);
}
getSuggestions() {
@@ -106,7 +106,7 @@ export default class SwitcherForm extends Component {
this.props.onSubmit(this.getSuggestions()[this.state.selected]);
}
handleKeyUp(event) {
handleKeyDown(event) {
switch (event.key) {
case "ArrowUp":
event.stopPropagation();
@@ -152,7 +152,7 @@ export default class SwitcherForm extends Component {
<form
onInput=${this.handleInput}
onSubmit=${this.handleSubmit}
onKeyUp=${this.handleKeyUp}
onKeyDown=${this.handleKeyDown}
>
<input
type="search"