Socket
Socket
Sign inDemoInstall

keydown-key

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.1

lib/index.d.ts

2

lib/index.js
/*! 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,(function(){return(()=>{"use strict";var e={d:(o,t)=>{for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{default:()=>t});const t=function(e){var o=e.key,t=e.keyCode,r=o;return t&&229===t&&(r="Process"),{key:r}};return o})()}));
!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,(function(){return(()=>{"use strict";var e={};return(()=>{var o=e;Object.defineProperty(o,"__esModule",{value:!0}),o.default=function(e){var o=e.keyCode,t=e.key;return o&&229===o&&(t="Process"),{key:t}}})(),e})()}));
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

/*! keydown-key v1.0.0 | (c) 2021 Mark Lin. | MIT | https://github.com/seawind543/keydown-key */
/*! keydown-key v1.1.1 | (c) 2021 Mark Lin. | MIT | https://github.com/seawind543/keydown-key */
{
"name": "keydown-key",
"version": "1.0.0",
"version": "1.1.1",
"description": "A utility function to normalize the KeyboardEvent.key especially during IME",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [

@@ -10,6 +11,8 @@ "lib"

"scripts": {
"prepublish": "yarn run eslint && yarn run clean && yarn run build",
"prepublish": "yarn run eslint && yarn run test && yarn run clean && yarn run build && yarn run clean:post",
"build": "webpack",
"clean": "rm -f {lib}/*",
"eslint": "eslint --max-warnings 0 --ext .js src"
"clean": "rm -f lib/*",
"clean:post": "rm -f lib/*.test.d.ts*",
"eslint": "eslint --max-warnings 0 --ext .js,.ts src",
"test": "jest --coverage"
},

@@ -34,21 +37,27 @@ "repository": {

],
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.14.8",
"@babel/eslint-parser": "^7.14.9",
"@babel/core": "^7.15.8",
"@babel/eslint-parser": "^7.15.8",
"@babel/eslint-plugin": "^7.14.5",
"@babel/preset-env": "^7.14.9",
"babel-loader": "^8.2.2",
"eslint": "^7.32.0",
"@babel/preset-env": "^7.15.8",
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^26.0.24",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"babel-loader": "^8.2.3",
"eslint": "^8.1.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^14.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-webpack-plugin": "^3.0.1",
"prettier": "^2.3.2",
"webpack": "^5.48.0",
"webpack-cli": "^4.7.2"
"jest": "26.6.3",
"prettier": "^2.4.1",
"ts-loader": "^9.2.6",
"typescript": "^4.4.4",
"webpack": "^5.59.1",
"webpack-cli": "^4.9.1"
}
}

@@ -9,10 +9,15 @@ [![NPM](https://nodei.co/npm/keydown-key.png?downloads=true&stars=true)](https://www.npmjs.com/package/keydown-key/)

To handle the different behaviors (with IME) between browsers on different OS.
To handle the different behaviors (with [IME](https://en.wikipedia.org/wiki/Input_method)) between browsers on different platforms.
- The keyDown.key behavior of Chrome is different on Mac and Windows
- Mac: key === `Enter` with IME
- Windows: key === `Process` with IME
- The keyDown.key behavior of Chrome and FireFox are different on Mac
- FireFox key === `Process` with IME for both Mac and Windows
> On the different `platform + browser`, the `keyDownEvent.key` has a different value when `selecting a CJK character` by press the `Enter key` with `IME`.
![[IME keyDown.key issue] Chrome on Mac](https://imgur.com/63EJixc)
Example: https://imgur.com/63EJixc
- With IME, the keyDown.key value of Chrome is different on Mac and Windows
- Mac: key === `Enter`
- Windows: key === `Process`
- With IME, the keyDown.key value of Chrome and FireFox are different on Mac
- FireFox key === `Process` on both Mac and Windows
### Playground

@@ -27,3 +32,3 @@

```cmd
```sh
yarn add keydown-key

@@ -41,3 +46,4 @@ ```

const { key } = keyDownKey(KeyboardEvent);
switch() {
switch(key) {
case 'Enter':

@@ -58,4 +64,10 @@ // Do what you want for real `Enter` key

## Reference
[1] IME https://en.wikipedia.org/wiki/Input_method
[2] CJK characters https://en.wikipedia.org/wiki/CJK_characters
## License
[MIT](./LICENSE)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc