Skip to contentSkip to navigationSkip to topbar
Paste assistant Assistant
Figma
Star

Keyboard Key

Version 1.0.0GithubStorybookPeer review pending

A Keyboard Key distinguishes a keyboard command or shortcut from other text.

Installation

Installation page anchor
yarn add @twilio-paste/keyboard-key - or - yarn add @twilio-paste/core
import { KeyboardKeyGroup, KeyboardKey } from '@twilio-paste/core/keyboard-key';

const KeyboardKeyExample = () => {
  return (
    <KeyboardKeyGroup>
      <KeyboardKey>Control</KeyboardKey>
      <KeyboardKey>B</KeyboardKey>
    </KeyboardKeyGroup>
  );
};

KeyboardKey

KeyboardKey page anchor

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
string
Default
'KEYBOARD_KEY'

keyEvent

Sets the key text that will be used to determine if the key has press stylings. A list of keyEvent mapping can be found at: https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/

Type
string
Default
'KEYBOARD_KEY'

activeKeys

The aray of currently active keys

Type
string[]
Default
[]

disabled

Whether the keys should show the disbled state

Type
boolean

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
string
Default
'KEYBOARD_KEY_GROUP'

enablePressStyles

Whether the keys should show pressed state when active keys contains the keyEvent mapped to KeyboardKey

Type
boolean

variant

The variant of the keys to display

Type
KeyboardKeyVariants
Default
'default'

combinations RequiredRequired

Type
Omit<useKeyCombinationProps, "enablePressStyles">[]

keys RequiredRequired

Type
string[]

onCombinationPress RequiredRequired

Type
() => void

disabled

Type
boolean

enablePressStyles

Type
boolean