{"id":28959651,"url":"https://github.com/seawind543/keydown-key","last_synced_at":"2026-02-18T12:31:40.380Z","repository":{"id":41311406,"uuid":"403040746","full_name":"seawind543/keydown-key","owner":"seawind543","description":"An utility to normalize the KeyboardEvent.key especially during IME composition","archived":false,"fork":false,"pushed_at":"2025-03-04T17:02:00.000Z","size":967,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-26T23:38:42.460Z","etag":null,"topics":["cross-browser","cross-platform","ime","javascript","keyboardevent","normalize","react","vanilla-javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seawind543.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-04T11:38:07.000Z","updated_at":"2025-03-04T05:07:11.000Z","dependencies_parsed_at":"2024-07-24T11:30:14.741Z","dependency_job_id":"c3dc46a6-7841-4932-a70c-6f04db53b6e1","html_url":"https://github.com/seawind543/keydown-key","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/seawind543/keydown-key","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seawind543%2Fkeydown-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seawind543%2Fkeydown-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seawind543%2Fkeydown-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seawind543%2Fkeydown-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seawind543","download_url":"https://codeload.github.com/seawind543/keydown-key/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seawind543%2Fkeydown-key/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29578952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T08:38:15.585Z","status":"ssl_error","status_checked_at":"2026-02-18T08:38:14.917Z","response_time":162,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-browser","cross-platform","ime","javascript","keyboardevent","normalize","react","vanilla-javascript"],"created_at":"2025-06-24T00:03:26.675Z","updated_at":"2026-02-18T12:31:40.367Z","avatar_url":"https://github.com/seawind543.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://nodei.co/npm/keydown-key.png?downloads=true\u0026stars=true)](https://www.npmjs.com/package/keydown-key/)\n\n# keydown-key\n\nAn utility to normalize the KeyboardEvent.key especially during IME composition\n\n## Why need this?\n\nTo address the inconsistent behavior of [IME](https://en.wikipedia.org/wiki/Input_method) across different browsers and platforms:  \n\nWhen selecting a [CJK character](https://en.wikipedia.org/wiki/CJK_characters) using the Enter key with IME, the `keyDownEvent.key` value varies depending on the platform and browser combination.  \n\n### IME `keyDown.key` Issue in Chrome on Mac  \n\n**Example:** [Screenshot](https://imgur.com/63EJixc)  \n\n#### Differences in `keyDown.key` Values with IME  \n\n- **Chrome:**  \n  - **Mac:** `key === \"Enter\"`  \n  - **Windows:** `key === \"Process\"`  \n\n- **Firefox:**  \n  - `key === \"Process\"` on both **Mac** and **Windows**  \n\nThis discrepancy can cause inconsistencies when handling keyboard events in web applications.\n\n### Playground\n\n- [Vanilla JS] https://codepen.io/seawind543/pen/gOWNVYR\n- [React JS] https://codepen.io/seawind543/pen/xxdvZyE\n\n## Installation\n\n1. Install the latest version of [keydown-key](https://github.com/seawind543/keydown-key):\n\n  ```sh\n  yarn add keydown-key\n  ```\n\n2. Apply `keydown-key` in your application\n\n### Example (Vanilla JS)\n\n  ```javascript\n  import keyDownKey from 'keydown-key';\n\n  // ... omit\n\n  function handleKeyDown(event: KeyboardEvent) { \n    const { key } = keyDownKey(event);\n\n    switch(key) {\n      case 'Enter':\n        // Do what you want for real `Enter` key\n        break;\n\n      case 'Process':\n        // The keyDown on \"Enter\" with IME will be here\n        break;\n\n      default: \n    }\n  }\n\n  inputBox.addEventListener('keydown', handleKeyDown);\n  ```\n\n### Example (React JS)\n\n  ```javascript\n  import React from \"react\";\n  import keydownKey from \"keydown-key\";\n\n  const handleKeyDown = (event: React.KeyboardEvent) =\u003e {\n    // use the `nativeEvent` attribute to get the browser KeyboardEvent\n    // https://reactjs.org/docs/events.html#overview\n    const { key } = keydownKey(event.nativeEvent);\n\n    switch(key) {\n      case 'Enter':\n        // Do what you want for real `Enter` key\n        break;\n\n      case 'Process':\n        // The keyDown on \"Enter\" with IME will be here\n        break;\n\n      default: \n    }\n  };\n\n  const App = () =\u003e {\n    return \u003cinput onKeyDown={handleKeyDown} /\u003e;\n  };\n\n  export default App;\n  ```\n\n## Reference\n\n[1] IME https://en.wikipedia.org/wiki/Input_method\n\n[2] CJK characters https://en.wikipedia.org/wiki/CJK_characters\n\n[3] add support for SyntheticKeyboardEvent#isComposing https://github.com/facebook/react/issues/13104\n\n[4] Support IME https://github.com/seawind543/react-token-input/issues/1#issuecomment-896190656\n\n[5] Element: keydown event https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition\n\n## License\n\n[MIT](./LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseawind543%2Fkeydown-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseawind543%2Fkeydown-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseawind543%2Fkeydown-key/lists"}