The UIKeyCommand class specifies a key presses performed on a hardware keyboard and the resulting action that should take place.
Questions tagged [uikeycommand]
41 questions
19
votes
1 answer
How can I make a UIKeyCommand with the return/enter key?
I'd like to make a UIKeyCommand that uses only the [return] key. So far I've tried:
UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];
There's no global constant for the enter…

paulrehkugler
- 3,241
- 24
- 45
17
votes
4 answers
Detect delete key using UIKeyCommand
Anyone know how to detect the "delete" key using UIKeyCommand on iOS 7?

Scotty
- 2,019
- 1
- 20
- 31
15
votes
4 answers
Detecting continuous key presses with UIKeyCommand
Is it possible to get continuous key presses?
I'm using keyCommands: to intercept the arrows keys being pressed on an external keyboard, but I only get 1 call per press. I would love to get either multiple calls every X milliseconds as long as the…

Christian A. Strømmen
- 3,181
- 2
- 25
- 46
8
votes
3 answers
SwiftUI iOS - how to capture hardware key events
I’m new to iOS development. Following a tutorial I have created a simple calculator using SwiftUI.
I have a keyboard attached to my iPad, and I would like to be able to enter values using the keyboard.
How can I capture and handle hardware keyboard…

Jesper Kristiansen
- 1,759
- 3
- 17
- 29
7
votes
3 answers
Stop UIKeyCommand repeated actions
If a key command is registered, it's action might be called many times if the user holds down the key too long. This can create very weird effects, like ⌘N could repeatedly open a new view many times. Is there any easy way to stop this behavior…

Brent
- 460
- 1
- 3
- 12
6
votes
2 answers
Keyboard shortcuts with UIKeyCommand in iPadOS 15 beta
For some reason I can't get hardware keyboard shortcuts to work in iPadOS 15 (beta 5). They work for most keys, but not for arrow keys and tab key.
The same code seems to work well when compiled in Xcode 13 (beta 4) and run on iPadOS 14.5 simulator,…

Alex Staravoitau
- 2,222
- 21
- 27
6
votes
0 answers
React Native: How to support an external iPad keyboard (UIKeyCommand)?
The iPad works with external bluetooth keyboards, and the iPad Pro has a Smart Keyboard, which you can support natively using the UIKeyCommand API.
How can I use these keyboard shortcuts in React Native?

bryanjclark
- 6,247
- 2
- 35
- 68
5
votes
1 answer
Try iPad Shortcuts in Simulator
With iOS 9 Developers can add Shortcuts to an iPad App using UIKeyCommand.
Those are typed on an external keyboard and a function reacts.
Is there a way to test those in the simulator on the mac?
Or show them like here:

Devhess
- 289
- 4
- 16
5
votes
1 answer
UIKeyCommand with modifier won't be recognized on first invocation
I support keyboard shortcuts in my iOS app through serving UIKeyCommand instances from my view controller.
The following works like a charm and causes the provided selector to be invoked every time you press e:
- (BOOL)canBecomeFirstResponder {
…

Leo
- 37,640
- 8
- 75
- 100
4
votes
1 answer
UIKeyCommand discoverabilityTitle deprecated
According to documentation convenience initializer with discoverabilityTitle is now deprecated:
// Key Commands with a discoverabilityTitle _will_ be discoverable in the UI.
@available(iOS, introduced: 9.0, deprecated: 13.0)
public…

Dmytro Rostopira
- 10,588
- 4
- 64
- 86
4
votes
0 answers
How to launch the Discoverability overlay programmatically when XCUI testing on iOS
The Discoverability overlay displays the available UIKeyCommands when a user connects a hardware keyboard to an iOS device.
A user launches the overlay by holding down the Command key.
XCUITests provide a high-level API to blackbox test your app, by…

jamesh
- 19,863
- 14
- 56
- 96
4
votes
1 answer
How to use UIKeyCommand
I'm trying to select a row in a table view when a user presses the down arrow on a hardware keyboard. For now, I'm just trying to print a log, and I can't seem to get it to work. As per the other similar questions' answers, here's what I have so…

ArielSD
- 829
- 10
- 27
4
votes
0 answers
UIKeyCommand Arrow Key Input Not Working
I have other UIKeyCommand's working properly, however the arrow key (using UIKeyInput[Direction]Arrow constants) selectors are not getting called. Any suggestions will be much appreciated.
This is the code I am using to create an arrow key…

DaveAMoore
- 621
- 4
- 11
4
votes
1 answer
iOS Swift Interrupt Keyboard Events
I have problem to intercept keyboard events. I have connected my iOS with SteelSeries Free (gamepad controller) which when connected to iOS will be detected as a Bluetooth Keyboard. This is tested when I open Notes, any button presses in the gamepad…

CodingBird
- 705
- 2
- 11
- 22
3
votes
2 answers
View controller's key commands are included when it presents modally
I'm working on adding keyboard shortcuts on my application. There is a view controller that presents another controller:
class ViewController: UIViewController {
override var canBecomeFirstResponder: Bool { true }
override func…

Andrii Chernenko
- 9,873
- 7
- 71
- 89