The system provides several types of onscreen keyboards, each designed to facilitate a different type of input. People can also connect an external keyboard to their iPad. When an external keyboard is available, people expect your app to support it by enabling keyboard shortcuts and keyboard navigation.
Match the onscreen keyboard to the type of content people are editing. For example, you can help people enter numeric data by providing the numbers and punctuation keyboard. For developer guidance, see UIKeyboardType.
Use the keyboard layout guide to make the keyboard feel like an integrated part of your interface. Using the layout guide also ensures that important UI remains accessible while the keyboard is onscreen. For guidance, see Layout Guides and Safe Areas.
To learn about creating a custom keyboard, see Custom Keyboards.
Responding to Keyboard Shortcuts on iPad
Keyboard shortcuts help people efficiently perform actions using only a hardware keyboard. iPad apps can support keyboard shortcuts for the system-defined commands — such as Undo, Redo, Paste and Match Style, and Print — in addition to providing custom shortcuts for app-specific commands.
In iPadOS 15 and later, an app’s keyboard shortcuts appear in the shortcut interface that displays when people hold the Command key. Similar in organization to an app’s menu bar menus on a Mac, the shortcut interface on iPad displays app commands in familiar system-defined menu categories such as File, Edit, and View. Unlike menu bar menus, the iPad interface displays all relevant categories in one view, listing within each category only available commands that also have shortcuts.
Because iPadOS keyboard shortcuts rely on the menu system, you add new shortcuts by adding new commands to the menu. For developer guidance, see UIMenuBuilder.
Avoid using the shortcut interface as the primary way to offer app functionality. The shortcut interface helps people learn about the keyboard shortcuts available to them, but it doesn’t list all the commands your app supports. Continue to use contextually relevant ways to present app functionality, like buttons and toolbars (for guidance, see Buttons and Toolbars).
Enable the system-defined keyboard shortcuts that make sense in your app. Help people learn your app quickly by supporting the system-defined keyboard shortcuts they already know.
Define new keyboard shortcuts for only the most common actions in your app. People appreciate using keyboard shortcuts for app-specific actions they perform frequently, but defining too many new shortcuts can clutter the shortcut interface and risk making your app seem difficult to learn. Minimizing app-specific keyboard shortcuts also helps avoid potential conflicts with system-defined shortcuts that may be in place. For guidance, see Defining Keyboard Shortcuts.
In general, don’t repurpose standard keyboard shortcuts for custom actions. People can get confused when the shortcuts they know work differently in your app. Only consider redefining a standard shortcut if its action doesn’t make sense in your app. For example, an app that doesn’t support text editing doesn’t need a text-styling command like Italic, so it might use Command–I for an action that has more relevance in the app, such as Get Info.
Provide descriptive command titles that help people discover available actions. Because the iPad shortcut interface displays a flat list of all items in each category, submenu titles aren’t available to provide context for their child items. For example, the item titles Name and Date Added don’t make sense without the context of the submenu title Sort Bookmarks By. You can enhance each item’s title by including the necessary context, such as Sort Bookmarks by Name and Sort Bookmarks by Date Added. For developer guidance, see discoverabilityTitle.
Let the system localize and mirror your keyboard shortcuts as needed. iPadOS automatically localizes a shortcut’s primary key and modifier keys to support the currently connected keyboard. Also, if your app switches to a right-to-left layout, the system automatically mirrors the shortcut. For related guidance, see Right to Left.
Support expected modifiers on drag interactions. For example, pressing Command while dragging moves items as a group; pressing Shift while drag-resizing constrains resizing to the item’s aspect ratio.
Meet people’s expectations when they continuously hold down a key. For example, holding an arrow key moves the selected item by the smallest app-defined unit of distance until people release the key.
Supporting Keyboard Navigation on iPad
Keyboard navigation lets people use a hardware keyboard to navigate an app’s key features and select items. By default, iPadOS 15 enables keyboard navigation in text fields, text views, and sidebars, providing APIs you can use to enable it in various types of collection views and other custom views in your app. For developer guidance, see Focus-Based Navigation.
IMPORTANT Avoid enabling keyboard navigation for controls, such as buttons, segmented controls, and switches. Full keyboard access already helps people activate controls, navigate to all onscreen elements, and even perform gesture-based interactions like drag and drop.
Beginning in iPadOS 15, keyboard navigation relies on the tvOS focus system, in which people perform actions by moving a focus indicator to an item and then selecting it (to learn more, see Focus and Selection). Although the underlying system is the same, the user experiences are a little different. tvOS uses directional focus, which means that people can use the same interaction — that is, swiping the Siri Remote or using only the arrow keys on a connected keyboard — to navigate to every onscreen element. In contrast, iPadOS defines focus groups, which represent specific areas within an app, like a sidebar, grid, or list. Using focus groups, iPadOS can support two different keyboard interactions.
- Pressing the Tab key moves focus among focus groups, letting people navigate to sidebars, grids, and other app areas.
- Pressing an arrow key enables a directional focus interaction that’s similar to tvOS, but limited to navigation among items in the same focus group. For example, people can use an arrow key to move through the items in a list or a sidebar.
Onscreen elements can indicate focus by using the halo effect or the highlighted appearance.
The halo focus effect — also known as the focus ring — displays a customizable outline around the element. You can apply the halo effect to custom views and to fully opaque content within a collection or list cell, such as an image.
Customize the halo focus effect when necessary. By default, the system uses an item’s shape to infer the shape of its halo. If the system-provided halo doesn’t give you the appearance you want, you can refine it to match contours like rounded corners or shapes defined by Bezier paths. You can also adjust a halo’s position if another element occludes or clips it. For example, you might need to ensure that a badge appears above the halo or that a parent view doesn’t clip it. For developer guidance, see UIFocusHaloEffect.
The highlighted appearance — in which the element’s background uses the app’s tint color — also indicates focus, but it’s not a focus effect. The highlight appearance occurs automatically when people select a collection view cell on which you’ve set background and content configurations (for developer guidance, see UICollectionViewCell).
Ensure that focus moves through your custom views in ways that make sense. As people continue pressing the Tab key, focus moves through focus groups in reading order: leading to trailing, and top to bottom. Although focus moves through system-provided views in ways that people expect, you might need to adjust the order in which the focus system visits your custom views. For example, if you want focus to move down through a vertical stack of custom views before it moves in the trailing direction to the next view, you need to identify the stack container as a single focus group. For developer guidance, see focusGroupIdentifier.
Adjust the priority of an item to reflect its importance within a focus group. When a group receives focus, its primary item automatically receives focus too, making it easy for people to select the item they’re most likely to want. You can make an item primary by increasing its priority. For developer guidance, see UIFocusGroupPriority.