in packages/web-components/fast-foundation/src/combobox/combobox.ts [402:476]
public keydownHandler(e: Event & KeyboardEvent): boolean | void {
const key = e.key;
if (e.ctrlKey || e.shiftKey) {
return true;
}
switch (key) {
case "Enter": {
this.updateValue(true);
if (this.isAutocompleteInline) {
this.filter = this.value;
}
this.open = false;
const controlValueLength = this.control.value.length;
this.control.setSelectionRange(controlValueLength, controlValueLength);
break;
}
case "Escape": {
if (!this.isAutocompleteInline) {
this.selectedIndex = -1;
}
if (this.open) {
this.open = false;
break;
}
this.value = "";
this.control.value = "";
this.filter = "";
this.filterOptions();
break;
}
case "Tab": {
this.updateValue();
if (!this.open) {
return true;
}
e.preventDefault();
this.open = false;
break;
}
case "ArrowUp":
case "ArrowDown": {
this.filterOptions();
if (!this.open) {
this.open = true;
break;
}
if (this.filteredOptions.length > 0) {
super.keydownHandler(e);
}
if (this.isAutocompleteInline) {
this.updateValue();
this.setInlineSelection();
}
break;
}
default: {
return true;
}
}
}