Esta página ainda não foi traduzida para o português, por isso aparece em 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.

Atualizado em
Press any key…
History

Seus dados nunca saem do seu computador. Todo o processamento acontece localmente no navegador.

Como 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.

Também pesquisado como: javascript keycode, keycode list, event.key, event.code, keyboard event viewer, key code checker, keycode finder.

Ferramentas que combinam com: 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.

Perguntas frequentes

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.
Posso instalar o JavaScript Keycode Finder como um aplicativo da web e usá-lo offline?
Sim. O JavaScript Keycode Finder é um aplicativo da web instalável (PWA) — instalado a partir do seu navegador, não baixado de uma loja de aplicativos. Clique em “Instalar aplicativo” na parte superior desta página no Chrome ou no Edge (Windows, macOS, Linux, ChromeOS) ou, no Android, use “Compartilhar” → “Adicionar à tela inicial” no iPhone e no iPad, ou “Arquivo” → “Adicionar ao Dock” no Safari 17+ em um Mac. Em seguida, ela se abre em uma janela própria com seu próprio ícone e, como é executada inteiramente no seu navegador, continua funcionando offline. O Firefox no desktop não permite a instalação de aplicativos da web. Como funciona a instalação.

Ferramentas relacionadas