Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The method to detect the keyDown event for space or tab keys when Full Keyboard Access is enabled is to implement the keyDown() method in the NSView or NSWindow subclass and check for the keyCode of the space or tab keys. For space key, the keyCode is 49 and for tab key, the keyCode is 48. The implementation of the keyDown() method will look something like this:

override func keyDown(with event: NSEvent) {
   if event.keyCode == 49 || event.keyCode == 48 {
      // Space or tab key is pressed
      // Perform the desired action
   } else {
      super.keyDown(with: event)
   }
}