swiftkeyboardxcode11numeric-keypaduikeycommand

UIKeyCommand for the Enter key on Mac keyboard's numeric keypad


I'm using the Xcode 11 beta and using Catalyst ("the checkbox") to run an iPad app on the Mac.

I've been able to use the following UIKeyCommands for input from the Mac keyboard:

//the delete button
UIKeyCommand(input: "\u{8}", modifierFlags: [], action: #selector(backspacePress))

//the "return" button
UIKeyCommand(input: "\r", modifierFlags: [], action: #selector(returnPress))

//the up arrow
UIKeyCommand(input: UIKeyCommand.inputUpArrow, modifierFlags: [], action: #selector(upPress))

//letters or numbers
UIKeyCommand(input: "1", modifierFlags: [], action:  #selector(keyPressed(sender:)))

When I create the key command input for a number, it works both with the top row of numbers above QWERTY and also on the keyboard's numeric keypad on the right side of the keyboard.

Does anybody know where I can find the correct escape sequence like \r or \u{8} that I can use to detect a key press on the "enter" key of the numeric keypad?

Thanks so much for any help!

enter image description here

(I did see that you can pass a modifier flag of .numericPad but I believe that is for iOS keyboards when in numeric mode)


Solution

  • The answer is:

    UIKeyCommand(input: "\u{3}", modifierFlags: [], action: #selector(enterPress))