
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
key-sequence
Advanced tools
A featherweight utility to detect a sequence of key presses or a stream, and call the supplied callback. Fast!
var keySequence = require('key-sequence'); // CommonJS
<script src="key-sequence.min.js"></script> // Browser
// Regex '+'/'*' (denotes repeatable characters)
// The below matches 'omg<enter>'/'omgggg<enter>'/'o mggggggg<enter>'
var onKey = keySequence(['o', '\s*', 'm', 'g+', '\n'], (evt) => {
// Do what needs to be done when the key sequence is detected.
console('OMG it works!', evt);
});
// Konami code
var onKey = keySequence([38, 38, 40, 40, 37, 39, 37, 39, 'b', 'a'], () => {
console.log('Achievement unlocked!!');
});
// Use with Observables
sourceKeyStream.subscribe(
k => onKey(k));
// Can pass keycode using e.which using jQuery or events.
$(document).keypress(function(e) {
onKey(e.which, e /* optional */);
});
// or pass the character itself.
onKey('x');
/* Some more supported keysequences: */
[17, 'c'] //The classic <ctrl> and 'c'
['I', '.*', 'U'] // I <anything in between> U
+ and * as wildcards to denote repeating characters.<ctrl>, <alt> in the sequence.\s, . etc.Using a regex is slow and cannot get less elegant, its O(n) in the size of your total input,
on every single keystroke.
key-sequence generates a DFA and maintains the state. O(1) every single keystroke.
Can think of it as a regex which accepts streaming input.
- Support for more Regex metacharacters like
|etc.

This is the DFA for the above example. key-sequence maintains the present state according to the key input.
Once the end state(4 in this case) is reached the supplied done callback is called.
If, at any point the input does not match a transition, we go back to the starting state (0).
FAQs
Detect a sequence of keys being pressed.
We found that key-sequence 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
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.