The Keyboard Lock and the Pointer Lock APIs require permission from Chrome 131

The Keyboard Lock API lets developers provide an immersive, full screen experience for a variety of use cases, including interactive websites, games, and remote desktop or application streaming. It does so by enabling websites to use all available keys allowed by the host operating system.

The Pointer Lock API lets a desktop application hide the pointer icon and interpret mouse motion for something else, like looking around in a 3D world.

From Chrome 131, using either of these two APIs requires permission. You can check for permission as shown in the following snippets:

const {state} = await navigator.permissions.query({name: 'pointer-lock'});
if (state === 'granted') {
  // The Pointer Lock API can be used.
}
const {state} = await navigator.permissions.query({name: 'keyboard-lock'});
if (state === 'granted') {
  // The Keyboard Lock API can be used.
}

There's no explicit need to ask for permission. If permission wasn't granted before, the browser will show a permission prompt upon the first request to lock the pointer or the keyboard.

Keyboard Lock API permission prompt.

Pointer Lock API permission prompt.