From 873fb669075455c5d19051a4d1c0ef9acefa39e8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 19 Feb 2023 16:16:35 -0800 Subject: [PATCH] macos: disable ApplePressAndHoldEnabled so that repeated key events work --- macos/Sources/GhosttyApp.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macos/Sources/GhosttyApp.swift b/macos/Sources/GhosttyApp.swift index 42997a606..3588f6031 100644 --- a/macos/Sources/GhosttyApp.swift +++ b/macos/Sources/GhosttyApp.swift @@ -11,6 +11,7 @@ struct GhosttyApp: App { /// The ghostty global state. Only one per process. @StateObject private var ghostty = GhosttyState() + @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate; var body: some Scene { WindowGroup { @@ -45,6 +46,15 @@ struct GhosttyApp: App { } } +class AppDelegate: NSObject, NSApplicationDelegate { + func applicationDidFinishLaunching(_ notification: Notification) { + UserDefaults.standard.register(defaults: [ + // Disable this so that repeated key events make it through to our terminal views. + "ApplePressAndHoldEnabled": false, + ]) + } +} + class GhosttyState: ObservableObject { enum Readiness { case loading, error, ready