{"id":28220959,"url":"https://github.com/morulus/press-any-key","last_synced_at":"2025-07-30T16:08:00.631Z","repository":{"id":57329928,"uuid":"170291591","full_name":"morulus/press-any-key","owner":"morulus","description":"CLI util Press any key to continue...","archived":false,"fork":false,"pushed_at":"2024-10-08T18:50:03.000Z","size":61,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T04:16:36.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morulus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-12T09:39:35.000Z","updated_at":"2025-02-22T04:25:18.000Z","dependencies_parsed_at":"2024-06-18T22:31:48.388Z","dependency_job_id":"a5fc00af-f7bf-4d55-885c-a833719299b2","html_url":"https://github.com/morulus/press-any-key","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"3a89b8d1d6fd47e1c096a73fcef134b065879865"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fpress-any-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fpress-any-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fpress-any-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fpress-any-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morulus","download_url":"https://codeload.github.com/morulus/press-any-key/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fpress-any-key/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259066868,"owners_count":22800220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-18T04:16:33.475Z","updated_at":"2025-06-10T11:32:26.786Z","avatar_url":"https://github.com/morulus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"press-any-key\n==\n\nA utility to launch the simplest confirmation dialog.\n\n```\nnpx -q press-any-key\nPress any key to continue...\n```\n\nIf user presses any key it will exit with code 0. In the case of pressing CTRL+C it will exit with code 1.\n\n## Install\n\nIf you wish to use the utility from a npm scripts, you can install it into your project as a usual npm dependency.\n\n```shell\nnpm install press-any-key --save-dev\n```\n\nBut you can also use [npx](https://www.npmjs.com/package/npx) to invoke the command without install.\n\n```\nnpx -q press-any-key\n```\n\n## Arguments\n\n```\npress-any-key \u003cmessage\u003e [...options]\n```\n\nBy the default, the message is `\"Press any key to continue...\"`, but if you would like you can specify your own message as the first argument.\n\n```shell\npress-any-key \"Press any key to run the application\"\n```\n\n**Options:**\n\n`--ctrlc \u003ccode\u003e` Exit code on pressing CTRL-C.\n`--preserve-log` Do not clean the message, after resolve\n`--hide-message` Do not show the massage\n\n## How to route\n\nYou can use standard bash logical operators `\u0026\u0026` and `||` to perform branching.\n\n```shell\nnpx -q press-any-key \u0026\u0026 echo \"A good choice!\" || echo \"Bye bye :(\"\n```\n\nOr you can rely on the fact that CTRL + C, by default, exits the process.\n\nFor example, you have a script that performs irreversible actions, and to avoid accidental execution of the script, you can add additional confirmation.\n\n```bash\necho 'You are about to delete all files in current directory'\nnpx -q press-any-key\nrm -rf *\n```\n\n```shell\nYou are about to delete all files in the current directory\nPress any key to continue...\n```\n\n## Programmatic usage\n\nYou can use the package _press-any-key_ API in your node.js script.\n\n```js\nconst pressAnyKey = require('press-any-key');\n\npressAnyKey()\n  .then(() =\u003e {\n    // ... User presses a key\n  })\n```\n\n### API\n\n```\npressAnyKey(message, options)\n```\n\nThe message is a string that will be displayed in the standard output before it starts to listen for key presses. Pass null if you'd like to use the default message.\n\n**Options:**\n\n  - **`ctrlC`** The exit code, or `\"reject\"` (do reject the promise), or false to perceive as pressing any key.\n  - **`preserveLog`** Preserve the message in the log\n  - **`hideMessage`** Do not show the message\n\nBy default, when the user presses CTRL+C, the function will exit the process. However, you can change the standard behavior of CTRL+C by passing the option ctrlC with the value \"reject\". In this case, pressing CTRL+C will not exit the process but will instead reject the promise.\n\n```js\nconst pressAnyKey = require('press-any-key');\n\npressAnyKey(\"Press any key to resolve, or CTRL+C to reject\", {\n  ctrlC: \"reject\"\n})\n  .then(() =\u003e {\n    console.log('You pressed any key')\n  })\n  .catch(() =\u003e {\n    console.log('You pressed CTRL+C')\n  })\n```\n\nAuthor\n--\n\nVladimir Kalmykov \u003cvladimirmorulus@gmail.com\u003e\n\nLicense\n--\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorulus%2Fpress-any-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorulus%2Fpress-any-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorulus%2Fpress-any-key/lists"}