The exitPointerLock asynchronously releases a pointer lock previously requested through Element.requestPointerLock.
The exitPointerLock asynchronously releases a pointer lock previously requested through Element.requestPointerLock.
To track the success or failure of the request, it is necessary to listen for the pointerlockchange and pointerlockerror events.
MDN
When the Pointer lock state changes—for example, when calling requestPointerLock, exitPointerLock, the user pressing the ESC key, etc.—the pointerlockchange event is dispatched to the document.
When the Pointer lock state changes—for example, when calling requestPointerLock, exitPointerLock, the user pressing the ESC key, etc.—the pointerlockchange event is dispatched to the document. This is a simple event and contains no extra data.
MDN
When there is an error caused by calling requestPointerLock or exitPointerLock, the pointerlockerror event is dispatched to the document.
When there is an error caused by calling requestPointerLock or exitPointerLock, the pointerlockerror event is dispatched to the document. This is a simple event and contains no extra data.
MDN
The pointerLockElement property provides the element set as the target for mouse events while the pointer is locked.
The pointerLockElement property provides the element set as the target
for mouse events while the pointer is locked.
It is null
if lock is pending, pointer is unlocked, or the target is
in another document.
MDN