fn translate_key_event(options: InputOptions, key_event: KeyEvent) -> Option<Event> {
    // On Windows events for releasing a key are produced
    // We skip these to avoid emitting 2 events per key press.
    // There is still a `Repeat` event for when a key is held that will pass through
    // this guard.
    if key_event.kind == KeyEventKind::Release {
        return None;
    }
    match key_event.code {
        KeyCode::Char('c') if key_event.modifiers == crossterm::event::KeyModifiers::CONTROL => {
            ctrl_c();
            Some(Event::InternalStop)
        }
        KeyCode::Char('c') if options.has_selection => Some(Event::CopySelection),
        // Interactive branches
        KeyCode::Char('z')
            if matches!(options.focus, LayoutSections::Pane)
                && key_event.modifiers == crossterm::event::KeyModifiers::CONTROL =>
        {
            Some(Event::ExitInteractive)
        }
        // If we're in interactive mode, convert the key event to bytes to send to stdin
        _ if matches!(options.focus, LayoutSections::Pane) => Some(Event::Input {
            bytes: encode_key(key_event),
        }),
        // If we're on the list and user presses `/` enter search mode
        KeyCode::Char('/') if matches!(options.focus, LayoutSections::TaskList) => {
            Some(Event::SearchEnter)
        }
        KeyCode::Esc if options.is_help_popup_open => Some(Event::ToggleHelpPopup),
        KeyCode::Esc if matches!(options.focus, LayoutSections::Search { .. }) => {
            Some(Event::SearchExit {
                restore_scroll: true,
            })
        }
        KeyCode::Enter if matches!(options.focus, LayoutSections::Search { .. }) => {
            Some(Event::SearchExit {
                restore_scroll: false,
            })
        }
        KeyCode::Up if matches!(options.focus, LayoutSections::Search { .. }) => {
            Some(Event::SearchScroll {
                direction: Direction::Up,
            })
        }
        KeyCode::Down if matches!(options.focus, LayoutSections::Search { .. }) => {
            Some(Event::SearchScroll {
                direction: Direction::Down,
            })
        }
        KeyCode::Backspace if matches!(options.focus, LayoutSections::Search { .. }) => {
            Some(Event::SearchBackspace)
        }
        KeyCode::Char(c) if matches!(options.focus, LayoutSections::Search { .. }) => {
            Some(Event::SearchEnterChar(c))
        }
        // Fall through if we aren't in interactive mode
        KeyCode::Char('h') => Some(Event::ToggleSidebar),
        KeyCode::Char('u') => Some(Event::ScrollUp),
        KeyCode::Char('d') => Some(Event::ScrollDown),
        KeyCode::PageUp | KeyCode::Char('U') => Some(Event::PageUp),
        KeyCode::PageDown | KeyCode::Char('D') => Some(Event::PageDown),
        KeyCode::Char('t') => Some(Event::JumpToLogsTop),
        KeyCode::Char('b') => Some(Event::JumpToLogsBottom),
        KeyCode::Char('m') => Some(Event::ToggleHelpPopup),
        KeyCode::Char('p') => Some(Event::TogglePinnedTask),
        KeyCode::Up | KeyCode::Char('k') => Some(Event::Up),
        KeyCode::Down | KeyCode::Char('j') => Some(Event::Down),
        KeyCode::Enter | KeyCode::Char('i') => Some(Event::EnterInteractive),
        _ => None,
    }
}
Converts a crossterm key event into a TUI interaction event
crates/turborepo-ui/src/tui/input.rs