Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
js-keycodes
Advanced tools
Identify and work with keyCodes on JavaScript
npm i -S js-keyCodes
First import the lib into your code:
import * as KeyCodes from 'js-keycodes';
Or individual functions:
import { isLetter, isNumber } from 'js-keycodes';
const myKeyCode = 90;
if (KeyCodes.isLetter(myKeyCode)) {
// Do stuff if your keyCode is a letter
}
const handleAnEvent = (event) => {
if (event.which === KeyCodes.ENTER) {
// Do your stuff here.
}
}
KeyCodes.isNumber()
Return true if the keyCode is a number from 0 to 9.
KeyCodes.isLetter()
Return true if the keyCode is a letter from A to Z.
KeyCodes.isNavigation()
Return true if the keyCode represents an Arrow key like UP, DOWN, LEFT or RIGHT.
KeyCodes.isWhitespace()
Return true if the keyCode represent ENTER, SPACE or TAB
KeyCodes.isF1ToF12()
Return true if the keyCode represent any of the F buttons from F1 to F12
KeyCodes.keyCodeToString()
Return a string representation of the keyCode.
const myLetter = KeyCodes.keyCodeToString(90);
// -> 'Z'
const myNumber = KeyCodes.keyCodeToString(50)
// '2'
KeyCodes.getKeyNameFromKeyCode()
Return a string representation based on the programmatic name of the keyCode
const myLetter = KeyCodes.getKeyNameFromKeyCode(90);
// -> 'Z'
const myNumber = KeyCodes.getKeyNameFromKeyCode(50);
// -> 'TWO'
const myKey = KeyCodes.getKeyNameFromKeyCode(13);
// -> 'ENTER'
const myF = KeyCodes.getKeyNameFromKeyCode(121);
// -> 'F10'
FAQs
Identify and work with keycodes on JavaScript
The npm package js-keycodes receives a total of 3 weekly downloads. As such, js-keycodes popularity was classified as not popular.
We found that js-keycodes 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.