onKeyDown method private presentation

Last updated: 2026-03-04T23:21:38.428Z

Metrics

LOC: 27 Complexity: 12 Params: 1

Signature

onKeyDown(e: KeyboardEvent): : void

Architecture violations

View all

  • [warning] max-cyclomatic-complexity: 'onKeyDown' has cyclomatic complexity 12 (max 10)

Source Code

  private onKeyDown(e: KeyboardEvent): void {
    const items = this.dropdown
      ? Array.from(this.dropdown.querySelectorAll<HTMLElement>(".fa-ss__opt"))
      : [];

    if (e.key === "ArrowDown") {
      e.preventDefault();
      if (!this._open) {
        this.open();
        return;
      }
      this._highlighted = Math.min(this._highlighted + 1, items.length - 1);
      this.highlightItem(items, this._highlighted);
    } else if (e.key === "ArrowUp") {
      e.preventDefault();
      this._highlighted = Math.max(this._highlighted - 1, 0);
      this.highlightItem(items, this._highlighted);
    } else if (e.key === "Enter") {
      e.preventDefault();
      const item = items[this._highlighted];
      if (item) {
        this.selectByValue(item.dataset.value!);
      }
    } else if (e.key === "Escape" || e.key === "Tab") {
      this.close();
    }
  }

No outgoing dependencies.

No incoming dependencies.