Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

JavaScript Keycode Finder — Key Event Info

Press any key and instantly see every property of the keyboard event, with a copy-ready keydown snippet for shortcuts.

Mis à jour le
Press any key…
History

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : JavaScript Keycode Finder

  1. Click the box (or anywhere on the page) and press a key or shortcut.
  2. Read event.key, event.code and the legacy keyCode.
  3. Copy the generated keydown handler for your shortcut.

key, code and keyCode

PropertyWhat it tells youUse it for
event.keyThe character or key name produced, respecting layout and Shift ("a", "A", "Enter")Text input, “type ? for help”
event.codeThe physical key position, independent of layout ("KeyA", "Digit1")Games (WASD) and position-based shortcuts
event.keyCode / whichLegacy numeric codes (Enter = 13, Esc = 27)Old code only — deprecated
event.location0 standard, 1 left, 2 right, 3 numpadTelling left/right Shift or numpad keys apart

Common key codes

Keyevent.keyevent.codekeyCode
EnterEnterEnter13
EscapeEscapeEscape27
Space" "Space32
TabTabTab9
BackspaceBackspaceBackspace8
Arrow keysArrowLeft/Up/Right/Downsame37–40
A–Za–z / A–ZKeyA–KeyZ65–90
0–90–9Digit0–Digit948–57
F1–F12F1–F12F1–F12112–123

Writing shortcut handlers

Check modifiers explicitly (e.ctrlKey || e.metaKey covers Ctrl on Windows and ⌘ on macOS), call e.preventDefault() only for shortcuts you handle, and skip your handler while the user types in inputs. Prefer key for letter shortcuts so they follow the user’s keyboard layout, and code when the physical position matters.

Test regular expressions for key handling in the regex tester, or check how the browser identifies itself with the user agent parser.

Aussi recherché comme : javascript keycode, keycode list, event.key, event.code, keyboard event viewer, key code checker, keycode finder.

Outils complémentaires : JavaScript Keycode Finder

  • Online HTML Editor — A lightweight code playground: edit HTML, CSS and JavaScript side by side, see the result instantly, read console output and download your page as one HTML file.
  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
  • What Is My Screen Resolution — Your screen and browser window sizes in CSS pixels, the device pixel ratio and the real physical resolution — measured live by your browser.
  • HTML Formatter — Paste minified or messy markup and get clean, consistently indented HTML — including embedded <style> and <script> blocks.

Questions fréquentes

Should I use keyCode?
No. keyCode and which are deprecated. Use event.key for the character and event.code for the physical key.
What is the keycode for Enter?
Enter has keyCode 13, key "Enter" and code "Enter" (or "NumpadEnter" on the numeric keypad).
Why does Ctrl+W close the tab?
Some browser shortcuts cannot be intercepted by web pages for security reasons, including Ctrl+W, Ctrl+T and Ctrl+N in most browsers.
Puis-je installer JavaScript Keycode Finder en tant qu’application web et l’utiliser hors ligne ?
Oui. JavaScript Keycode Finder est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires