Skip to Content
Platform.Ontology

Keyboard and IME events

Sees every key pressed while the page has focus, plus IME composition text.

Gets silentlyTyping and clipboardTextWeb browsersWhile you use it

In one line

Can see each key you press while the page has focus

Sees every key pressed while the page has focus, plus IME composition text.

A page that has focus gets each keydown with the key and its physical code, and exact timing. Typing rhythm can identify a person; composition events reveal the language they type in.

What it can and can't do

What the user does: Nothing. It happens as you type while the page is open and in front

It can

  • See which key you pressed and the exact time
  • Tell the difference between a typed letter and a shortcut like Ctrl plus C
  • Learn your typing rhythm, which can help tell people apart
  • See text from input method editors, which can show the language you type in

It cannot

  • See keys pressed in other tabs or other apps
  • See anything while the page is in the background
  • Show a permission pop up; there is none

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported12008-12-11None
EdgeSupported122015-07-29None
FirefoxSupported1.52005-11-29None
SafariSupported1.22004-02-02None
Safari on iPhoneSupported12007-06-29All iOS browsers use WebKit
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APIkeydown, keyup, beforeinput, input, compositionstart/update/end; KeyboardEvent.key, .code, .timeStamp
Browser compat keysapi.KeyboardEvent
api.InputEvent
api.CompositionEvent
How access is grantednone
What the user seesNone (no browser prompt)
Needs a secure context (HTTPS)No
Needs a user gestureNo
Activationnone
How long it lastsWhile the document has focus
How to take it backNothing to revoke (no permission is stored)
Inside an iframeKeys go to the focused frame only; cross-origin iframes do not leak keys to the parent

Typical flow

  1. Person types in the page
  2. keydown and input events fire
  3. Page reads key, code, isComposing and data

Data you get

What comes back: Key events with timestamps
Shape: event
How often: per keystroke

FieldTypeUnitRangePrecision
keystringNonecharacter or named keyexact
codestringNonephysical key positionexact
timeStampfloatmsfrom page load100 us in Chrome, about 1 ms in Firefox and Safari

Technical limits

  • No key events for text typed in other tabs, apps, the address bar or OS dialogs
  • Event timeStamp is a DOMHighResTimeStamp: 100 microseconds in Chrome, coarser in Firefox and Safari (about 1 ms)
  • Password fields still fire keydown (the page owner can read what is typed there)
  • During IME composition keydown carries key Process (keyCode 229); the composed text comes through compositionend and beforeinput
  • Browsers cannot hide key timing; keystroke dynamics identify users at roughly 1 to 5 percent equal error rate in research

The story

What it is

The page sees every key you press while it is focused, including timing.

For you

You press keys and the page reacts: a game character moves, a shortcut opens a menu, a search box suggests words. You do not see that each key and its exact timing was noticed. The page only sees keys while it is the active window.

For makers

Keys drive games, shortcuts, forms and chat. Makers also use typing speed and rhythm for fraud and bot checks, and some analytics tools record keystrokes in forms.

Where you see it

TypeExampleApps
gamesA browser shooter reads WASD, space and shift every frame so your character moves and jumps.Krunker.io, Slither.io
gamesA cloud gaming site such as GeForce NOW sends each key press to the remote machine to play a PC game in the browser.GeForce NOW, Xbox Cloud Gaming
creativeA design tool uses key shortcuts such as V for move and Space to pan.Figma, Canva
bankingA bank login checks typing rhythm to judge whether the same person is typing as always.None named
analyticsA session recording tool replays how visitors typed in a form and where they gave up.Hotjar, FullStory
securityA bot detector flags forms filled in perfectly even typing speed with no pauses.None named
accessibilityA web app offers keyboard only control for people who cannot use a mouse.None named

Risks

  • Typing rhythm identifies people
  • Keystrokes can be recorded

Good uses and abuse

Legitimate uses

  • Games
  • Shortcuts
  • Rich editing
  • Accessibility

Known abuse

  • Keylogging typed form data in injected scripts
  • Behavioral biometrics (typing cadence)
  • Session replay capture of keystrokes

Scores

ScoreValueMeaning
Sensitivity4 of 5How revealing the data is
Utility5 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits5Rough identifying entropy, when known

History

  • 2016, Chrome 51: KeyboardEvent.code standardized in Chrome
  • 2019-09, Chrome 77: beforeinput event with inputType values

Sources

How well checked: Based on official documentation.

On this page