Re: [whatwg/fullscreen] Add keyboard locking option (PR #232)

zcorpan left a comment (whatwg/fullscreen#232)

> As a developer, I would like to note that there is exactly one problem with the current draft/implementation: it is impossible to check the presence or absence of `keyboardLock` support on the target browser without having to call `requestFullscreen()`. There is no any flag or property that we could use for this. And even after the call, the code does not know whether it intercepts all key events.
> 
> If this is not supported, it would be great to be able to distinguish between these states to alert the user who expects all his keys to be intercepted.
> 
> It might not be too late to add something for that.

It's possible to feature-check that the `keyboardLock` dictionary member is supported without going fullscreen like this: https://software.hixie.ch/utilities/js/live-dom-viewer/saved/14660

This doesn't tell you whether a particular value is supported until actually going fullscreen, though. This step:

> If FullscreenOptions 's[ keyboardLock ](https://whatpr.org/fullscreen/232/2263e15...f670402.html#dom-fullscreenoptions-keyboardlock)'s value is not supported, reject promise with a NotSupportedError exception and terminate these steps.

Runs after rejecting when |error| is true, so you can only tell that the value is supported by going fullscreen with requesting `keyboardLock` (and checking that the dictionary member is supported first, since unknown dictionary members are silently ignored).

While this method of checking dictionary members has been deemed sufficient for feature-checking in some cases, I could be convinced that it's not ideal DX and there should be a property similar to `document.fullscreenEnabled` (e.g. `document.keyboardLockEnabled`) to allow easy feature-checking and easy checking if keyboard lock is currently active. (If we drop `system` then this becomes a boolean.)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fullscreen/pull/232#issuecomment-4252884710
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fullscreen/pull/232/c4252884710@github.com>

Received on Wednesday, 15 April 2026 14:25:39 UTC