@@ -15,12 +15,12 @@ use global_hotkey::{GlobalHotKeyEvent, HotKeyState};
1515
1616use iced:: futures:: SinkExt ;
1717use iced:: futures:: channel:: mpsc:: { Sender , channel} ;
18- use iced:: window;
1918use iced:: {
2019 Element , Subscription , Task , Theme , futures,
2120 keyboard:: { self , key:: Named } ,
2221 stream,
2322} ;
23+ use iced:: { event, window} ;
2424
2525use objc2:: rc:: Retained ;
2626use objc2_app_kit:: NSRunningApplication ;
@@ -136,8 +136,18 @@ impl Tile {
136136 /// - Keypresses (escape to close the window)
137137 /// - Window focus changes
138138 pub fn subscription ( & self ) -> Subscription < Message > {
139+ let keyboard = event:: listen_with ( |event, _, id| match event {
140+ event:: Event :: Keyboard ( keyboard:: Event :: KeyPressed { key, .. } ) => match key {
141+ keyboard:: Key :: Named ( keyboard:: key:: Named :: Escape ) => {
142+ Some ( Message :: EscKeyPressed ( id) )
143+ }
144+ _ => None ,
145+ } ,
146+ _ => None ,
147+ } ) ;
139148 Subscription :: batch ( [
140149 Subscription :: run ( handle_hotkeys) ,
150+ keyboard,
141151 Subscription :: run ( handle_recipient) ,
142152 Subscription :: run ( handle_hot_reloading) ,
143153 Subscription :: run ( handle_clipboard_history) ,
0 commit comments