ink-cartridge
    Preparing search index...

    Function KeyboardProvider

    • Provides the keyboard system to the component tree.

      Instantiates a KeyboardEngine (kept alive across renders via a ref, or supplied via the engine prop), keeps it in sync with the screen system's layer state, and feeds Ink's key events — and mouse events when mouse is enabled — into the pipeline. Must be nested inside a ScenarioManagementProvider.

      The engine is registered for module-level access (see getEngine, withOwner, and the moduleApi functions) during render, not only in an effect: React runs child effects before the parent's, so effect-only registration would leave the engine unresolvable for a child that calls the module-level API from its own effect.

      Returns Element

      The full provider chain. modes registers the mode names before any binding can be restricted to them (defaultMode must be one of them). With mouse enabled, SGR mouse reports are filtered out of the keyboard stream automatically, so they never reach useInput handlers as text.

      import { ScenarioManagementProvider, KeyboardProvider, CurrentScreen } from 'ink-cartridge';

      function App() {
      return (
      <ScenarioManagementProvider defaultScreen={MainScreen} fullScreen>
      <KeyboardProvider modes={['normal', 'insert']} defaultMode="normal" mouse>
      <CurrentScreen />
      </KeyboardProvider>
      </ScenarioManagementProvider>
      );
      }