# Key hint

An input hint: a key glyph and what it does, optionally pressable.

[View Key hint on CyberSpec](https://www.cyberspec.dev/components/sidebar/key-hint)

## Component

Key hint belongs to the Actions group in the CyberSpec catalog. It uses markup and CSS.

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/key-hint.json
```

## Example

```tsx
"use client"

import * as React from "react"
import { KeyHint, KeyHints } from "@/components/ui/key-hint"

// The foot of an inventory screen. Equip and Drop are buttons too, for a
// pointer; a carbine in hand can't be dropped.
export default function KeyHintDemo() {
  const [equipped, setEquipped] = React.useState(true)
  return (
    <>
      <span data-kit="value" role="status">
        KR-9 // {equipped ? "EQUIPPED" : "STOWED"}
      </span>
      <KeyHints
        align="center"
        hints={[
          { keys: ["↑", "↓"], label: "Navigate" },
          { keys: "↵", label: "Open" },
          { keys: "E", label: "Equip", onPress: () => setEquipped((now) => !now) },
          { keys: "X", label: "Drop", onPress: () => {}, disabled: equipped },
        ]}
      />
      <KeyHint keys="Esc" label="Close" />
    </>
  )
}
```

## Install this example

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/key-hint-demo.json
```

## Resources

- [Interactive Key hint preview](https://www.cyberspec.dev/preview/key-hint)
- [Component catalog](https://www.cyberspec.dev/components.md)
- [Key hint source code](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/ui/key-hint.tsx)
- [Shadcn registry item](https://www.cyberspec.dev/r/key-hint.json)
