Effortlessly build beautiful command-line apps - an opinionated, pre-styled wrapper around @clack/core
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Global configuration utilities for customizing key bindings and interaction behavior across all @clack/prompts components.
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):"
});@clack/prompts comes with these default key aliases pre-configured:
k (up), j (down), h (left), l (right)Ctrl+C and Escape both trigger canceltype 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 promptupdateSettings() only adds new aliases, it won't overwrite existing onesupdateSettings() accumulate aliases'K' and 'k' are different)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',
}
});Settings configuration works with all prompt types:
text() and password() - Navigation for cursor movementconfirm() - Navigation between Yes/No optionsselect() and multiselect() - Menu navigation and selectionselectKey() and groupMultiselect() - All navigation and selection actions'\x03' for Ctrl+C)