Overview

Show keyboard shortcuts contextually.

Import

import { KeyHint } from 'nikcli-tui';

Usage

new KeyHint({ parent: screen, hints: [{ key: 'q', label: 'quit' }] });

Live Preview

Run Locally

npm run tsx:core-gallery

Props

  • hints: Array of { key: string; label: string } — Key + label pairs.
  • separator?: string — Spacing string (default 3 spaces).
  • showBrackets?: boolean — Surround keys with [ ] (default true).

Methods

  • setHints(hints), addHint(hint), removeHint(key), clearHints().
  • setSeparator(text), setShowBrackets(bool).

Installation

npm i nikcli-tui

Import

import { KeyHint } from 'nikcli-tui';

Quick Start

new KeyHint({ parent: screen, top: 1, left: 2, hints: [ { key: 'q', label: 'quit' }, { key: 'enter', label: 'select' } ] });

Production Examples

new KeyHint({ parent: screen, top: 2, left: 2, hints: [ { key: 'h', label: 'help' }, { key: 'f', label: 'find' } ], separator: '  ' });

Best Practices

  • Mostra solo scorciatoie rilevanti al contesto attuale.