Questions tagged [uikeycommand]
The UIKeyCommand class specifies a key presses performed on a hardware keyboard and the resulting action that should take place.
uikeycommand
41
questions
19
votes
1
answer
4k
views
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(...
18
votes
4
answers
6k
views
Detect delete key using UIKeyCommand
Anyone know how to detect the "delete" key using UIKeyCommand on iOS 7?
15
votes
4
answers
4k
views
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 ...
8
votes
3
answers
4k
views
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 ...
7
votes
3
answers
773
views
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. ...
6
votes
2
answers
2k
views
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 ...
6
votes
0
answers
375
views
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 ...
5
votes
1
answer
1k
views
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 ...
5
votes
1
answer
439
views
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 ...
4
votes
1
answer
3k
views
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 ...
4
votes
1
answer
2k
views
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 ...
4
votes
1
answer
1k
views
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, ...
4
votes
0
answers
129
views
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 ...
4
votes
0
answers
867
views
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 ...
3
votes
2
answers
606
views
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 ...
3
votes
1
answer
3k
views
Listening for hardware keyboard key presses in Swift
I'd like to add hardware keyboard support to my app so users may trigger a function to be called by pressing a certain key on the keyboard at any time. I found this article and was able to make it ...
3
votes
1
answer
896
views
iOS Navigate TableView with Arrow Keys
How can a UITableView be navigated with arrow keys (physical keyboard) much like the spotlight behavior that was introduced in iOS 10?
Looking to have a user type into a search box and use the up/...
3
votes
0
answers
201
views
Using arrow keys to navigate a UITableView
I would like to be able to traverse a UITableView using a physical keyboard's arrow keys then use the enter key to select a row. Normally the user would type into a UISearchBar then select a result ...
2
votes
1
answer
1k
views
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
...
2
votes
1
answer
2k
views
command key in iOS simulator
The iOS simulator shortcuts frequently use the command key. I notice that when running in the simulator, attempts in my program to catch command-z, command-y, etc. don't work. I assume the reason is ...
2
votes
1
answer
344
views
SwiftUI iOS - how to use captured hardware key events
How can I use the pressed key information in my SwiftUI?
I try to use @EnvironmentObject to share key with my SwiftUI but i get every time crash in sendKeybKey: Thread 1: Fatal error: No ...
2
votes
1
answer
404
views
Different UIKeyCommand arrays for different view controllers in Swift
I have a problem with UIKeyCommand in Swift. I have two UIViewVontroller, ProjectsViewController and ViewController. I'm opening ViewController from ProjectsViewController using this code:
let editor ...
1
vote
1
answer
515
views
Detect shift + return key when UITextView is the responder
I want to detect if the user presses either just "return" key or "shift+return" key on the external keyboard to perform two different actions when the UITextView is the responder.
...
1
vote
1
answer
324
views
UISplitviewController and different UIKeyCommands depending on master, detail or both being on screen
I want to include some UIKeyCommands in my app. My app consists of one UISplitViewController that forces the master to be always visible on iPad full screen. On smaller screen it works like it ...
1
vote
0
answers
301
views
Swift set textview font programmatically only for new text typed not all text
I'm using UIKeyCommands to allow users with a bluetooth keyboard to use CMD + B for bold and CMD + I for italic.
I've managed to do this successfully here ...
@objc func boldText() {
...
1
vote
0
answers
537
views
React Native: add keyboard shortcuts to iOS app
So I was trying add keyboard shortcuts to my React Native iOS app. So that users can with an external keyboard on the iPad can take advantage of those shortcuts.
I've created an AppDelegate.swift and ...
1
vote
0
answers
190
views
ctrl + enter seems not working with UIKeyCommand
I am trying to interfere with the external hardware keyboard's inputs on an iOS system.
Everything works well except for one problem: After attempt to register CTRL + ENTER with code
UIKeyCommand(...
1
vote
1
answer
1k
views
how to intercept key event of swift iOS app?
I deleted the @UIApplicationMain in AppDelegate.swiftand wrote the main.swift as below , but the program still can not fire keyPressed function. But executes print("send event2") every keydown.
How ...
1
vote
0
answers
216
views
UIAlertController hides almost all UIKeyCommands
When a UIAlertController is presented, all UIKeyCommands from the responder chain are hidden besides the UITabBarController. The only key commands that work are: Escape, to dismiss the alert, and ...
0
votes
2
answers
789
views
How to detect a Command C in my app (Swift)?
I have a calculator app written in Swift, and it's fully compatible with custom keyboard shortcuts.
I'm trying call a method when the user presses Command + C, however, whenever I try to assign the ...
0
votes
2
answers
455
views
add variable to all UIViewControllers
I'm new to Swift and I'm trying to implement a custom UIKeyCommand architecture in a practice app. I wrote the extension below for the base UISplitViewController to show all UIKeyCommands in the ...
0
votes
2
answers
326
views
How to handle uppercase and lowercase characters when using UIKeyCommand
We are in the process of receiving and processing keyboard input.
Among my source code,
UIKeyCommand *menuKey = [UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:@"%c", 77]
...
0
votes
1
answer
857
views
UIKeyCommands not working
I'm trying to add custom shortcuts for iPad to my app. However, with the code below I can't get to see them working. When I press the command key I get the discovery modal, but when I then press ...
0
votes
1
answer
195
views
UIKeyCommands of custom UITableView not recognized
I have a UITableView subclass that has the keyCommands property implemented, where there are several UIKeyCommands provided. This UITableView is a subview of the main view in the View Controller.
...
0
votes
1
answer
89
views
How to determine the source of unwanted iPadOS external keyboard shortcuts in a multiple window app?
At the time of writing, I’m developing with Xcode 14.2 and iPadOS 16.3.1.
I am updating an existing app to support multiple windows/scenes for iPadOS. The main scene uses UIKit and the child scenes ...
0
votes
1
answer
39
views
How to implement support for copy keyboard shortcut in UICollectionViewCell?
If you implement override func copy(_ sender: Any?) {} in a view controller, present that view controller, then hold down command the keyboard shortcuts overlay appears revealing Copy is an available ...
0
votes
0
answers
27
views
Cmd+B in UIKeyComands not displaying first typed "b" afetr using the command - swift
I'm using UIKeyCommands - Cmd+B to bold text. The code works fine to bold the text. But after i use the Cmd+B and when I type "b" the first time it doesn't display on my textView.
Here's the ...
0
votes
0
answers
109
views
How do I write this in swift? Related to UIKeyCommand
How do I convert this into swift?
This code takes the keyCommand:
export function isBackspace(keyCode: number): boolean {
return keyCode === 8;
}
export function isDeleteForward(
...
0
votes
1
answer
343
views
UIResponder: keyCommands not called; confirmed isFirstResponder
My app has a passcode view, conceptually similar to the iOS unlock screen. It's a UIViewController that I present within a new UIWindow. Works fine. I'm adding the capability to type the passcode ...
0
votes
1
answer
272
views
Detect key press without modifier
I'd like to capture a keypress in my Catalyst app.
UIKeyCommand(input: "", modifierFlags: nil, action: #selector(singleShift))
Unfortunately modifierFlags can't be nil and NSEvent isn't supported ...
0
votes
1
answer
811
views
iOS Swift keyCommands Reading Numbers Only
Please consider the following code:
override var keyCommands: [UIKeyCommand]? {
var commands:[UIKeyCommand] = []
let numbers = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"...