macOS Key Event Slow Repeat
问题 I'm trying to create a small WASD demo game in macOS. I'm using NSEvent for handling the key events. To detect the key presses, I'm searching for keyDown events. Here's what I have: NSEvent.addLocalMonitorForEvents(matching: .keyDown) { (keyEvent) -> NSEvent? in if self.keyDown(with: keyEvent) { return nil } else { return keyEvent } } func keyDown(with event: NSEvent) -> Bool { userInt.keyDown(key: event.characters) return true } So here, I'm holding the keys down (as you'd expect in a game),