Skip to Content
Platform.Ontology

Keyboard Lock

Lets a fullscreen page capture shortcut keys like Esc, Alt+Tab or Ctrl+W (Chromium only).

Works without askingScreen and windowsInput captureWeb browsersWhile you use it

In one line

Can capture shortcut keys like Esc or Ctrl+W, but only in fullscreen on Chromium

Lets a fullscreen page capture shortcut keys like Esc, Alt+Tab or Ctrl+W (Chromium only).

A site can keep keys the browser or OS would normally take, which remote desktops, games and cloud IDEs need. It also lets a hostile fullscreen page swallow the usual escape shortcuts for a moment.

What it can and can't do

What the user does: You tap Fullscreen in a game, remote desktop or web editor.

It can

  • Capture chosen shortcut keys so a game or remote desktop receives them
  • Release them when you leave fullscreen

It cannot

  • Start without a click, tap or keypress
  • Block system shortcuts the computer keeps for itself
  • Stop you leaving fullscreen, since holding Esc for about two seconds still exits
  • Keep capturing after you leave fullscreen

How it differs between platforms: Chrome and Edge on computers only. Firefox and Safari do not support it.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported682018-07-24None
EdgeSupported792020-01-15None
FirefoxNot supportedNot availableNot listedNone
SafariNot supportedNot availableNot listedNone
Safari on iPhoneNot supportedNot availableNot listedNone
Chrome on AndroidSupported682018-07-24None
Samsung InternetSupported10.02019-08-22None

How a site asks for it

APInavigator.keyboard.lock(['Escape','KeyW']); navigator.keyboard.unlock()
Browser compat keysapi.Keyboard.lock
api.Keyboard.unlock
How access is grantedgesture
What the user seesNo prompt (needs a click, tap or keypress)
Needs a secure context (HTTPS)Yes
Needs a user gestureYes
Activationtransient
How long it lastsEnds on unlock(), leaving fullscreen or navigation; nothing is stored
How to take it backNothing to revoke (no permission is stored)
Inside an iframeNeeds the frame to be fullscreen, so cross-origin iframes need allow="fullscreen"

Typical flow

  1. Person clicks
  2. Page enters fullscreen
  3. Page calls navigator.keyboard.lock() with a list of key codes
  4. Chosen keys go to the page instead of the browser

Data you get

Shape: none

No individual data fields. The signal is the access itself.

Technical limits

  • Chrome and Edge only (no Firefox, no Safari, no iOS)
  • Works only while the page is fullscreen in Chrome; locking Escape means the person must hold Esc for about 2 s to leave fullscreen
  • Keys are named by physical KeyboardEvent.code values, not characters
  • Some combinations stay with the OS or browser, such as Ctrl+Alt+Del and system shortcuts like the macOS app switcher
  • Cannot lock keys while the tab is in the background

The story

What it is

Lets a full screen page capture shortcut keys like Esc, Alt+Tab or Ctrl+W (Chromium only).

For you

In full screen, keys like Esc and Alt+Tab may go to the page instead of your computer. A hint tells you to hold Esc to leave.

For makers

It makes cloud gaming and remote desktops feel like the real thing, because every key reaches the game or the far computer. Sites must be in full screen first.

Where you see it

TypeExampleApps
gamesA cloud gaming site sends every key to the game, including Windows and Esc, so menus and chat work.Xbox Cloud Gaming, GeForce NOW
enterpriseA remote desktop in the browser passes Ctrl+W and Alt+Tab to the far computer instead of closing your tab.Chrome Remote Desktop
gamesA browser shooter keeps Esc for its own pause menu rather than letting the browser grab it.None named
educationA coding class sandbox keeps shortcuts inside the editor so students do not close the tab by mistake.None named
securityAn exam site locks keys to block tab switching, which students and critics find invasive.None named
creativeA music or video editor in full screen uses every key for its own shortcuts.None named

Risks

  • Can block escape routes
  • Chromium only

What the platform says

  • MDN: Keyboard API. Explains how a page can lock keys such as Esc and system shortcuts while in full screen.

Good uses and abuse

Legitimate uses

  • Remote desktop and VM consoles
  • Browser games
  • Cloud IDEs and terminals

Known abuse

  • Trapping the person in a fullscreen spoof that eats Esc and Ctrl+W
  • Hiding shortcut use from the person

Scores

ScoreValueMeaning
Sensitivity3 of 5How revealing the data is
Utility3 of 5How useful it is to honest apps
Friction1 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2018-07, Chrome 68: Keyboard Lock API ships on desktop
  • 2020-01, Edge 79: Available in Chromium based Edge

Sources

How well checked: Based on official documentation.

On this page