Esta página aún no está traducida al español, así que la mostramos en inglés.

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.

Actualizado el
Press any key…
History

Tus datos nunca salen de tu ordenador. Todo se procesa localmente en tu navegador.

Cómo usar: 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.

También se busca como: javascript keycode, keycode list, event.key, event.code, keyboard event viewer, key code checker, keycode finder.

Herramientas que combinan con: 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.

Preguntas frecuentes

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.
¿Puedo instalar JavaScript Keycode Finder como aplicación web y utilizarla sin conexión?
Sí. JavaScript Keycode Finder es una aplicación web instalable (PWA): se instala desde el navegador, no se descarga desde una tienda de aplicaciones. Haz clic en «Instalar aplicación» en la parte superior de esta página en Chrome o Edge (Windows, macOS, Linux, ChromeOS) o, en Android, utiliza «Compartir» → «Añadir a la pantalla de inicio» en iPhone y iPad, o «Archivo» → «Añadir al Dock» en Safari 17+ en un Mac. A continuación, se abrirá en su propia ventana con su propio icono y, como se ejecuta íntegramente en tu navegador, seguirá funcionando sin conexión. Firefox en el ordenador de sobremesa no permite instalar aplicaciones web. Cómo funciona la instalación.

Herramientas relacionadas