Ga naar hoofdinhoud
Logo Appt Light

Keyboard order on iOS

By adjusting the keyboard order, you can provide a great experience for users that control their device using a hardware keyboard.

On iOS, you can use the accessibilityRespondsToUserInteraction attribute to optimize keyboard navigation. By setting the property to false, the element will be skipped with keyboard navigation. Other assistive technologies, such as VoiceOver can still focus on the element. This way you can provide screen reader users with alternative text for images, but skip focus for keyboard users. When a hardware keyboard is connected and VoiceOver is enabled, the image will be focusable.

For even more concise control over the keyboard order, you can use properties such as canBecomeFocused,focusGroupIdentifier and focusGroupPriority. To debug focus, you can use UIFocusDebugger.

A use case could be a grid where you want to navigate by rows. You can achieve this by setting the same focusGroupIdentifier for each column in a row.

grid.topLeft.focusGroupIdentifier = "top"
grid.topRight.focusGroupIdentifier = "top"
grid.bottomLeft.focusGroupIdentifier = "bottom"
grid.bottomRight.focusGroupIdentifier = "bottom"
Bijdragen

Feedback?

Laat 't ons weten!