import { ModifierKey, SpecialKey } from "./keypress-constants"; /** * This class is immutable. In order to create an instance of it, please use the factory methods: * createFromInk, createFromKeypress, createCopyOf * * Once an instance is created, only two mutation methods are provided which don't modify the * original instance and return a newly deep copied instance: * setModifierKeyFrom, setModifierKey * * A key press can be one of three things: * 1. A char & Modifier keys (shift, meta, ctrl). * 2. A special key (enter, left, right, backspace, etc) & Modifier keys. * 3. Just modifier keys (not currently supported) * * ENHANCEMENT: https://github.com/r3bl-org/r3bl-cmdr/issues/1 * * Currently this works for Ink's abstraction of key presses (via useInput) and it works when * directly using Node.js readline's raw mode (keypress events). Howeever, there are severe * limitations in both Ink and Node.js's handling of keypresses into a terminal that will * require this functionality to be written natively in Rust (see gh issue above). */ export declare class Keypress { readonly _key: (SpecialKey & ModifierKey) | undefined; readonly _input: string | undefined; /** * Don't deep copy all the provided arguments, use them as is. Use builders instead. */ private constructor(); static buildMutable: (key?: (SpecialKey & ModifierKey) | undefined, input?: string | undefined) => Keypress; /** @immutable */ static buildImmutable: (key?: (SpecialKey & ModifierKey) | undefined, input?: string | undefined) => Readonly; /** @immutable */ makeImmutable: () => Readonly; /** @immutable */ setModifierKey: (modifier: "shift" | "ctrl" | "meta", value: boolean) => Readonly; get input(): string; get key(): string; toString: () => string; /** Key is special if it can be pressed independently of input, eg: "upArrow" and "downArrow". */ isSpecialKey: () => boolean; /** * Key is modifier if "ctrl", "meta", or "shift" is true. */ isModifierKey: () => boolean; matches: (selector: string) => boolean; /** * If _key is defined, then return it as a string (in lowercase), eg: "backspace", "downarrow". */ private convertKeyToString; }