macos: disable ApplePressAndHoldEnabled so that repeated key events work

This commit is contained in:
Mitchell Hashimoto
2023-02-19 16:16:35 -08:00
parent 1e09a1f2e1
commit 873fb66907

View File

@ -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