Keyboard key

Keyboard key is used to educate merchants about keyboard shortcuts.

Use to list a related set of keyboard shortcuts.

import {KeyboardKey} from '@shopify/polaris';
import React from 'react';

function Example() {
  return <KeyboardKey>Ctrl</KeyboardKey>;
}

Props

Want to help make this feature better? Please share your feedback.

interface KeyboardKeyProps
children?string

The content to display inside the key.

Best practices

The keyboard key component should:

  • Include a heading to introduce and explain the shortcuts being described when more than one shortcut is listed
  • Include an action label to describe what will happen if merchants use the key combination

Content guidelines

Heading

Headings above the keyboard key should:

Shortcut description

The shortcut description should describe what action is taken when merchants tap certain keys. When a hotkey combination takes merchants to a location in the interface, the format should be:

PropertiesTypeDescription
childrenstringThe content to display inside the key


Accessibility

The text of the keyboard key component is read by screen readers, but the visual formatting isn’t conveyed. Ensure that merchants are able to understand information about keyboard shortcuts without relying on the visual style of the component.

Do

  • Pair lists of keyboard shortcut information with a heading that describes the section (“Keyboard shortcuts”).
  • Provide inline keyboard instructions with context.
Example
Press the <KeyboardKey>Ctrl</KeyboardKey> key.

Don't

  • Use the keyboard key component alone to convey keyboard instructions.
Example
Use <KeyboardKey>Ctrl</KeyboardKey>