
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@ejames9/keylistener
Advanced tools
A `keys` function which can be used for listening for/reacting to keystrokes..
keyListener is little node program that simply listens for user definable keybindings, and executes associated callbacks. It is essentially a wrapper around This npm module called keypress, with a few default keybindings...
$ npm i @ejames9/keylistener --save-dev
Firstly, you must get your keys function from the keyListener package, like so:
const keys = require('@ejames9/keylistener')
Then you may use it like such:
keys((ch, key)=> {
// if you pressed `ctrl-p`
if (key.ctrl && key.name === 'p') {
// Do amazing things!!!
}
})
-NOTE The listener does not listen system-wide. At this time, it only works within the context of the terminal. It can't, for example, 'hear' a keypress in the terminal made while working in a text-editor.
The keys() function takes a callback as it's only argument, and it
takes 2 arguments -- ch (for character) and key. ch will give you access
to a character value, i.e. 'a' or 'z' and key will give you an object that
resembles thusly:
{
name: 'x',
ctrl: true,
meta: false,
shift: false,
sequence: '\u0018'
}
By default, ctrl-x and ctrl-c will exit the process, which you will need to use,
because the task you use keys() in will not finish on it's own. ctrl-w will
pause the listener, so that you may exit or unpause the the process, but your
callback will not be called, even if you hit your designated keybindings.
Admittedly this package is a bit on the hacky side, but it fulfills a unique purpose for me, and maybe it will for you as well. Happy Coding!!
FAQs
A `keys` function which can be used for listening for/reacting to keystrokes..
We found that @ejames9/keylistener demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.