pub struct KeyPressEvent {
pub key: KeyInput,
pub session_id: SessionId,
pub client_id: ClientId,
}Expand description
Key press event emitted when a key is received.
This event is emitted by the runner’s event loop and handled by registered key handlers. The handler performs key resolution and returns state changes via the result holder.
§Synchronous Processing
Key events are processed synchronously via bus.emit() because:
- Key handling must complete before the next key is read
- State mutations need to happen in order
- Latency requirements demand immediate processing
§Session Routing
The session_id and client_id identify which session should
process the key. Handlers filter events by session ID.
§Example
use reovim_kernel::api::v1::{EventBus, EventResult};
use reovim_kernel::api::v1::events::{KeyInput, KeyCode, Modifiers, priority};
use reovim_kernel::api::v1::events::key::{KeyPressEvent, SessionId, ClientId};
let bus = EventBus::new();
// Register handler for session 0
let session_id = SessionId::new(0);
let _sub = bus.subscribe::<KeyPressEvent, _>(priority::CORE, move |event| {
if event.session_id != session_id {
return EventResult::NotHandled;
}
// Process key...
EventResult::Handled
});
// Emit key event
let key = KeyInput {
key: KeyCode::Char('j'),
modifiers: Modifiers::NONE,
};
bus.emit(KeyPressEvent::new(key, SessionId::new(0), ClientId::new(1)));Fields§
§key: KeyInputThe key input from the input driver.
session_id: SessionIdSession ID for routing.
client_id: ClientIdClient ID that originated this key.
Implementations§
Trait Implementations§
Source§impl Clone for KeyPressEvent
impl Clone for KeyPressEvent
Source§fn clone(&self) -> KeyPressEvent
fn clone(&self) -> KeyPressEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyPressEvent
impl Debug for KeyPressEvent
Source§impl Event for KeyPressEvent
impl Event for KeyPressEvent
Source§impl PartialEq for KeyPressEvent
impl PartialEq for KeyPressEvent
impl Eq for KeyPressEvent
impl StructuralPartialEq for KeyPressEvent
Auto Trait Implementations§
impl Freeze for KeyPressEvent
impl RefUnwindSafe for KeyPressEvent
impl Send for KeyPressEvent
impl Sync for KeyPressEvent
impl Unpin for KeyPressEvent
impl UnsafeUnpin for KeyPressEvent
impl UnwindSafe for KeyPressEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more