diff options
author | 2024-01-16 13:28:00 +0100 | |
---|---|---|
committer | 2024-01-16 13:28:00 +0100 | |
commit | 64d1ce5532f55d152fa5819532a138da2dca1a39 (patch) | |
tree | 1a242bde122b5e715f2e980c5541353e2ae8b048 /examples/stopwatch | |
parent | 534c7dd7b0bc515c31b6de87b4aa6a35b44c46a0 (diff) | |
download | iced-64d1ce5532f55d152fa5819532a138da2dca1a39.tar.gz iced-64d1ce5532f55d152fa5819532a138da2dca1a39.tar.bz2 iced-64d1ce5532f55d152fa5819532a138da2dca1a39.zip |
Refactor `KeyCode` into `Key` and `Location`
Diffstat (limited to 'examples/stopwatch')
-rw-r--r-- | examples/stopwatch/src/main.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs index 0b0f0607..8a0674c1 100644 --- a/examples/stopwatch/src/main.rs +++ b/examples/stopwatch/src/main.rs @@ -86,12 +86,16 @@ impl Application for Stopwatch { }; fn handle_hotkey( - key_code: keyboard::KeyCode, + key: keyboard::Key, _modifiers: keyboard::Modifiers, ) -> Option<Message> { - match key_code { - keyboard::KeyCode::Space => Some(Message::Toggle), - keyboard::KeyCode::R => Some(Message::Reset), + use keyboard::key; + + match key.as_ref() { + keyboard::Key::Named(key::Named::Space) => { + Some(Message::Toggle) + } + keyboard::Key::Character("r") => Some(Message::Reset), _ => None, } } |