pub async fn handle_key(&mut self, event: KeyEvent) -> Result<bool, Error> {
        let type_ = match event.inner {
            Some(ui_input3::KeyEvent { type_: Some(type_), .. }) => type_,
            // The key event here can't be handled without a type.
            // This might or might not be an error case, and should be validated elsewhere.
            _ => return Ok(false),
        };
        match type_ {
            ui_input3::KeyEventType::Sync => {
                self.keys_pressed.insert(event.key);
                Ok(true)
            }
            ui_input3::KeyEventType::Cancel => {
                self.keys_pressed.remove(&event.key);
                Ok(true)
            }
            ui_input3::KeyEventType::Pressed => {
                let key = event.key;
                let was_handled = self.trigger_matching_shortcuts(event).await;
                self.keys_pressed.insert(key);
                was_handled
            }
            ui_input3::KeyEventType::Released => {
                let key = event.key;
                let was_handled = self.trigger_matching_shortcuts(event).await;
                self.keys_pressed.remove(&key);
                was_handled
            }
        }
    }
/// Handles a key event:
/// - keeps state of pressed keys
/// - detects shortcuts
/// - notifies matching shortcut listeners
/// Returns `true` if shortcut was handled.
Handles a key event:
keeps state of pressed keys
detects shortcuts
notifies matching shortcut listeners
Returns `true` if shortcut was handled.
Handles a key event : keeps state of pressed keys detects shortcuts notifies matching shortcut listeners Returns ` true ` if shortcut was handled .
pub async fn handle_key(&mut self, event: KeyEvent) -> Result<bool, Error> {
        let type_ = match event.inner {
            Some(ui_input3::KeyEvent { type_: Some(type_), .. }) => type_,
            // The key event here can't be handled without a type.
            // This might or might not be an error case, and should be validated elsewhere.
            _ => return Ok(false),
        };
        match type_ {
            ui_input3::KeyEventType::Sync => {
                self.keys_pressed.insert(event.key);
                Ok(true)
            }
            ui_input3::KeyEventType::Cancel => {
                self.keys_pressed.remove(&event.key);
                Ok(true)
            }
            ui_input3::KeyEventType::Pressed => {
                let key = event.key;
                let was_handled = self.trigger_matching_shortcuts(event).await;
                self.keys_pressed.insert(key);
                was_handled
            }
            ui_input3::KeyEventType::Released => {
                let key = event.key;
                let was_handled = self.trigger_matching_shortcuts(event).await;
                self.keys_pressed.remove(&key);
                was_handled
            }
        }
    }
pub async fn handle_key ( & mut self , event : KeyEvent ) -> Result < bool , Error > { let type_ = match event . inner { Some ( ui_input3 :: KeyEvent { type_ : Some ( type_ ) , .. } ) => type_ , // The key event here can't be handled without a type. // This might or might not be an error case, and should be validated elsewhere. _ => return Ok ( false ) , } ; match type_ { ui_input3 :: KeyEventType :: Sync => { self . keys_pressed . insert ( event . key ) ; Ok ( true ) } ui_input3 :: KeyEventType :: Cancel => { self . keys_pressed . remove ( & event . key ) ; Ok ( true ) } ui_input3 :: KeyEventType :: Pressed => { let key = event . key ; let was_handled = self . trigger_matching_shortcuts ( event ) . await ; self . keys_pressed . insert ( key ) ; was_handled } ui_input3 :: KeyEventType :: Released => { let key = event . key ; let was_handled = self . trigger_matching_shortcuts ( event ) . await ; self . keys_pressed . remove ( & key ) ; was_handled } } }
Handles a key event:
 keeps state of pressed keys
 detects shortcuts
 notifies matching shortcut listeners
Returns `true` if shortcut was handled.
Handles a key event : keeps state of pressed keys detects shortcuts notifies matching shortcut listeners Returns ` true ` if shortcut was handled .
&mut self
event
KeyEvent
&mut self
event
KeyEvent