or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced-workflows.mdcancellation-handling.mdindex.mdinteractive-prompts.mdlogging-system.mdprogress-indicators.mdselection-prompts.mdsession-management.mdsettings-configuration.md
tile.json

settings-configuration.mddocs/

Settings Configuration

Global configuration utilities for customizing key bindings and interaction behavior across all @clack/prompts components.

Capabilities

Update Settings

Configure global aliases for keyboard shortcuts and actions across all prompt types.

/**
 * Set custom global aliases for the default actions.
 * This will not overwrite existing aliases, it will only add new ones!
 * 
 * @param updates - Configuration object containing aliases
 */
function updateSettings(updates: ClackSettings): void;

interface ClackSettings {
  /** An object that maps key aliases to actions */
  aliases: Record<string, Action>;
}

type Action = 'up' | 'down' | 'left' | 'right' | 'space' | 'enter' | 'cancel';

Usage Examples:

import { updateSettings, text } from "@clack/prompts";

// Add custom vim-style navigation (these are actually built-in by default)
updateSettings({
  aliases: {
    'k': 'up',      // k key for up navigation
    'j': 'down',    // j key for down navigation
    'h': 'left',    // h key for left navigation
    'l': 'right',   // l key for right navigation
  }
});

// Add custom shortcuts for other keys
updateSettings({
  aliases: {
    'w': 'up',      // w key for up
    's': 'down',    // s key for down
    'a': 'left',    // a key for left
    'd': 'right',   // d key for right
    'q': 'cancel',  // q key to cancel
  }
});

// Now use prompts with your custom key bindings
const choice = await text({
  message: "Enter some text (use your custom keys for navigation):"
});

Default Key Bindings

@clack/prompts comes with these default key aliases pre-configured:

  • Vim Navigation: k (up), j (down), h (left), l (right)
  • Cancellation: Ctrl+C and Escape both trigger cancel
  • Standard Navigation: Arrow keys, Enter, Space work as expected

Available Actions

type Action = 
  | 'up'      // Navigate up in menus
  | 'down'    // Navigate down in menus  
  | 'left'    // Navigate left or backward
  | 'right'   // Navigate right or forward
  | 'space'   // Toggle selection in multi-select
  | 'enter'   // Confirm/submit current selection
  | 'cancel'; // Cancel/abort current prompt

Configuration Behavior

  • Non-overwriting: updateSettings() only adds new aliases, it won't overwrite existing ones
  • Global Scope: Settings apply to all prompt instances created after the update
  • Additive: Multiple calls to updateSettings() accumulate aliases
  • Case Sensitive: Key aliases are case-sensitive ('K' and 'k' are different)

Advanced Configuration

import { updateSettings } from "@clack/prompts";

// Configure for left-handed users
updateSettings({
  aliases: {
    'i': 'up',
    'k': 'down',
    'j': 'left',
    'l': 'right',
  }
});

// Add numeric keypad support
updateSettings({
  aliases: {
    '8': 'up',
    '2': 'down',
    '4': 'left',
    '6': 'right',
    '5': 'enter',
    '0': 'cancel',
  }
});

// Custom gaming-style controls
updateSettings({
  aliases: {
    'w': 'up',
    's': 'down',
    'a': 'left',
    'd': 'right',
    'f': 'enter',
    'x': 'cancel',
  }
});

Compatibility

Settings configuration works with all prompt types:

  • text() and password() - Navigation for cursor movement
  • confirm() - Navigation between Yes/No options
  • select() and multiselect() - Menu navigation and selection
  • selectKey() and groupMultiselect() - All navigation and selection actions

Important Notes

  • Settings must be configured before creating prompts to take effect
  • Key aliases are global and persist for the entire application session
  • Special characters and control sequences can be used as keys (e.g., '\x03' for Ctrl+C)
  • The original default keys (arrows, Enter, Escape, etc.) always remain functional