pub trait KeyHandler: Send + 'static {
// Required method
fn handle_key(
&mut self,
key: KeyEvent,
context: &KeyContext,
) -> AppKeyResult;
// Provided method
fn status_hint(&self) -> Option<String> { ... }
}Expand description
Trait for customizing key handling at the App level.
Implement this to customize how keys are processed BEFORE they reach widgets or default text input handling.
§Key Flow
Key Press
|
KeyHandler.handle_key(key, context) <- context.widget_blocking tells if modal is open
|
If NotHandled -> Widget dispatch (modals like QuestionPanel get the key)
|
If still unhandled -> Default text input handlingRequired Methods§
Sourcefn handle_key(&mut self, key: KeyEvent, context: &KeyContext) -> AppKeyResult
fn handle_key(&mut self, key: KeyEvent, context: &KeyContext) -> AppKeyResult
Handle a key event.
Called for every key press. Return:
NotHandledto pass to widgets and default handlingHandledto consume the keyAction(...)to execute an app action
§Arguments
key- The key eventcontext- Current app context (input state, processing state, etc.)
Provided Methods§
Sourcefn status_hint(&self) -> Option<String>
fn status_hint(&self) -> Option<String>
Get a status hint to display in the status bar.
This allows the handler to provide context-sensitive hints, such as “Press again to exit” when in exit confirmation mode.