diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 7f6005dd8..57bfba828 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -685,6 +685,18 @@ class AppDelegate: NSObject, } private func localEventKeyDown(_ event: NSEvent) -> NSEvent? { + // If the tab overview is visible and escape is pressed, close it. + // This can't POSSIBLY be right and is probably a FirstResponder problem + // that we should handle elsewhere in our program. But this works and it + // is guarded by the tab overview currently showing. + if event.keyCode == 0x35, // Escape key + let window = NSApp.keyWindow, + let tabGroup = window.tabGroup, + tabGroup.isOverviewVisible { + window.toggleTabOverview(nil) + return nil + } + // If we have a main window then we don't process any of the keys // because we let it capture and propagate. guard NSApp.mainWindow == nil else { return event }