Skip to content

[Request]: Support <Esc> key for canceling? #125

Closed
@rschristian

Description

@rschristian

Is your feature request related to a problem? Please describe.

Many CLIs (anecdotally, all the ones I use) support using <Esc> to exit, and as such, it's become muscle memory for me. However, only <C-c> is built in as a way to cancel, so I'm currently resorting to patch-package to add it in.

Figured I'd at least ask before I continued w/ patching.

Describe the solution you'd like

Ideally, just adding <Esc> alongside <C-c>:

        }
-        if (char === '\x03') {
+        if (char === '\x03' || key.name === 'escape') {
            this.state = 'cancel';
        }

https://github.com/natemoo-re/clack/blob/593f93d06c1a53c8424e9aaf0c1c63fbf6975527/packages/core/src/prompts/prompt.ts#L186-L188

Describe alternatives you've considered

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions