#434·prompts

A prompt of `type` "select" will not run `onCancel()` when ESC is pressed.

Author: MaxylanCreated Nov 7, 2025Updated Nov 7, 2025

Describe the bug

Title says it all ~ A prompt of type "select" does not run onCancel() when ESC is pressed.

To Reproduce

Create a prompt w/ a onCancel arrow method, like..

javascript
const response = await prompts(
    [
        {
            name: 'pick',
            type: 'select',
            message: 'Pick a choice',
            choices //: [..],
        },
    ],
    {
        onCancel: () => {
            console.log('» Interrupted by user');
            process.exit(1);
        },
    },
);

Run your program, press "ESC" as you encounter the prompt.

Expected behavior

Pressing "ESC" to cancel should invoke the onCancel() method, exiting the process

System

  • OS: wsl Linux, Ubuntu
  • (Linux C-5CG4301X0H 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux)
  • Terminal: bash
  • Node version: v22.15.0