Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Easy and free library for binding keys.
Keycharm is on npm so you can install it with:
npm install keycharm
After importing the script keycharm
is availible globally:
<script src="https://unpkg.com/keycharm/keycharm.js">
const keycharm = require('keycharm');
import keycharm from 'keycharm';
var keys = keycharm(options);
keys.bind("a", function () {}, 'keydown'); // key, callback function, 'keydown' or 'keyup'
{
/* optional div to bind keycharm to.
* It will NEED a tabindex. When not supplied, this defaults to window. */
container: document.getElementById("element"),
/* swallow events (default: false) */
preventDefault: false
}
'a'-'z', 'A'-'Z', '0'-'9', 'space', 'enter', 'ctrl', 'alt', 'tab', 'shift', 'delete', 'backspace', '-', '=', '[', ']',
'esc', 'F1'-'F12', 'pageup', 'pagedown',
'left', 'up', 'right', 'down',
'num0'-'num9', 'num/', 'num*', 'num-', 'num+', 'num.'
Each initiation of keycharm has its own bindings to the key events.
/* bind key, type = 'keydown' or 'keyup', default type = keydown. */
.bind(key, callback, [type]);
/* unbind key, type = 'keydown' or 'keyup', default type = keydown. No callback deletes all bound callbacks from key */
.unbind(key, [callback], [type]);
/* remove all bound keys */
.reset();
/* remove all bound keys and the event listeners of keycharm */
.destroy();
/* get the key label of the event */
.getKey(event);
/* bind all keys to this function, could be used for testing or demos. */
.bindAll(function, 'keydown' or 'keyup');
Common Pitfalls:
You might feel tempted to use the keycharm library to bind keys to elements other than just form elements. Great, however, in this case you should be aware of the fact that besides giving focus to the element (e.g. programmatically element.focus()
) you also need to add a tabindex! Simply focussing will not work.
Keycharm is Dual-licensed with both the Apache 2.0 license as well as the MIT license. I'll leave it up to the user to pick which one they prefer.
FAQs
Simple, lightweight key-binding lib
The npm package keycharm receives a total of 290,150 weekly downloads. As such, keycharm popularity was classified as popular.
We found that keycharm 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.