keydown-key
Advanced tools
Comparing version 1.3.0-beta.2 to 1.4.0
@@ -1,7 +0,6 @@ | ||
/// <reference types="react" /> | ||
export interface NormalizedKeyDownKey { | ||
declare type NormalizedKeyDownKey = { | ||
key: KeyboardEvent['key']; | ||
} | ||
declare function keyDownEventPropsNormalizer(keyDownEvent: KeyboardEvent | React.KeyboardEvent): NormalizedKeyDownKey; | ||
}; | ||
declare function keyDownEventPropsNormalizer(keyDownEvent: KeyboardEvent): NormalizedKeyDownKey; | ||
export default keyDownEventPropsNormalizer; | ||
//# sourceMappingURL=index.d.ts.map |
/*! For license information please see index.js.LICENSE.txt */ | ||
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports["keydown-key"]=o():e.KeyDownKey=o()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var o=e;Object.defineProperty(o,"__esModule",{value:!0}),o.default=function(e){var o=e.key;return 229===e.keyCode&&(o="Process"),{key:o}}})(),e})())); | ||
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports["keydown-key"]=o():e.KeyDownKey=o()}(this,(()=>(()=>{"use strict";var e={};return(()=>{var o=e;Object.defineProperty(o,"__esModule",{value:!0}),o.default=function(e){var o=e.key;return 229===e.keyCode&&(o="Process"),{key:o}}})(),e})())); | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
/*! keydown-key v1.3.0-beta.2 | (c) 2022 Mark Lin. | MIT | https://github.com/seawind543/keydown-key */ | ||
/*! keydown-key v1.4.0 | (c) 2024 Mark Lin. | MIT | https://github.com/seawind543/keydown-key */ |
{ | ||
"name": "keydown-key", | ||
"version": "1.3.0-beta.2", | ||
"version": "1.4.0", | ||
"description": "A utility function to normalize the KeyboardEvent.key especially during IME", | ||
@@ -36,16 +36,13 @@ "main": "lib/index.js", | ||
], | ||
"dependencies": { | ||
"@types/react": ">=16.9.56" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.18.6", | ||
"@babel/eslint-parser": "^7.18.2", | ||
"@babel/core": "^7.18.9", | ||
"@babel/eslint-parser": "^7.18.9", | ||
"@babel/eslint-plugin": "^7.17.7", | ||
"@babel/preset-env": "^7.18.6", | ||
"@babel/preset-env": "^7.18.9", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@types/jest": "^28.1.4", | ||
"@typescript-eslint/eslint-plugin": "^5.30.5", | ||
"@typescript-eslint/parser": "^5.30.5", | ||
"@types/jest": "^28.1.6", | ||
"@typescript-eslint/eslint-plugin": "^5.30.7", | ||
"@typescript-eslint/parser": "^5.30.7", | ||
"babel-loader": "^8.2.5", | ||
"eslint": "^8.19.0", | ||
"eslint": "^8.20.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
@@ -57,3 +54,3 @@ "eslint-config-airbnb-typescript": "^17.0.0", | ||
"eslint-webpack-plugin": "^3.2.0", | ||
"jest": "^28.1.2", | ||
"jest": "^28.1.3", | ||
"prettier": "^2.7.1", | ||
@@ -60,0 +57,0 @@ "ts-loader": "^9.3.1", |
@@ -36,4 +36,6 @@ [![NPM](https://nodei.co/npm/keydown-key.png?downloads=true&stars=true)](https://www.npmjs.com/package/keydown-key/) | ||
2. At this point you can import `keydown-key` in your application by: | ||
2. Apply `keydown-key` in your application | ||
### Example (Vanilla JS) | ||
```javascript | ||
@@ -44,4 +46,4 @@ import keyDownKey from 'keydown-key'; | ||
function handleKeyDown(KeyboardEvent) { | ||
const { key } = keyDownKey(KeyboardEvent); | ||
function handleKeyDown(event: KeyboardEvent) { | ||
const { key } = keyDownKey(event); | ||
@@ -64,2 +66,33 @@ switch(key) { | ||
### Example (React JS) | ||
```javascript | ||
import React from "react"; | ||
import keydownKey from "keydown-key"; | ||
const handleKeyDown = (event: React.KeyboardEvent) => { | ||
// use the `nativeEvent` attribute to get the browser KeyboardEvent | ||
// https://reactjs.org/docs/events.html#overview | ||
const { key: theNormalizedKey } = keydownKey(event.nativeEvent); | ||
switch(key) { | ||
case 'Enter': | ||
// Do what you want for real `Enter` key | ||
break; | ||
case 'Process': | ||
// The keyDown on "Enter" with IME will be here | ||
break; | ||
default: | ||
} | ||
}; | ||
const App = () => { | ||
return <input onKeyDown={handleKeyDown} />; | ||
}; | ||
export default App; | ||
``` | ||
## Reference | ||
@@ -66,0 +99,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7884
0
0
0
103
8
- Removed@types/react@>=16.9.56
- Removed@types/prop-types@15.7.12(transitive)
- Removed@types/react@18.3.1(transitive)
- Removedcsstype@3.1.3(transitive)