pub(crate) fn handle_character_input(
    app: &mut Application,
    char: char,
    modifiers: KeyModifiers,
) -> Result<bool, Box<dyn Error>> {
    if modifiers == KeyModifiers::CONTROL {
        return handle_control_options(char, app);
    } else if modifiers == KeyModifiers::ALT {
        match char {
            '=' => {
                app.labels.update_stream_length(cmp::min(app.labels.get_stream_length() + 1, 64));
                app.labels.update_streams(&app.data.contents[app.data.offset..]);
            }
            '-' => {
                app.labels.update_stream_length(cmp::max(
                    app.labels.get_stream_length().saturating_sub(1),
                    0,
                ));
                app.labels.update_streams(&app.data.contents[app.data.offset..]);
            }
            _ => {}
        }
    } else if modifiers | KeyModifiers::NONE | KeyModifiers::SHIFT
        == KeyModifiers::NONE | KeyModifiers::SHIFT
    {
        let is_hex = app.key_handler.is_focusing(Window::Hex);

        match char {
            'q' if is_hex => {
                if !app.key_handler.is_focusing(Window::UnsavedChanges) {
                    if !app.data.dirty {
                        return Ok(false);
                    }
                    app.set_focused_window(Window::UnsavedChanges);
                }
            }
            'h' if is_hex => {
                app.key_handler.left(&mut app.data, &mut app.display, &mut app.labels);
            }
            'l' if is_hex => {
                app.key_handler.right(&mut app.data, &mut app.display, &mut app.labels);
            }
            'k' if is_hex => {
                app.key_handler.up(&mut app.data, &mut app.display, &mut app.labels);
            }
            'j' if is_hex => {
                app.key_handler.down(&mut app.data, &mut app.display, &mut app.labels);
            }
            '^' if is_hex => {
                app.key_handler.home(&mut app.data, &mut app.display, &mut app.labels);
            }
            '$' if is_hex => {
                app.key_handler.end(&mut app.data, &mut app.display, &mut app.labels);
            }
            '/' if is_hex => {
                app.set_focused_window(Window::Search);
            }
            _ => {
                app.key_handler.char(&mut app.data, &mut app.display, &mut app.labels, char);
            }
        }
    }
    Ok(true)
}
Handles a character key press. While used predominantly to edit a file, it also checks for
any shortcut commands being used.
src/input.rs