JavaScript document.pointerLockElement Property
You are Here:
JavaScript document.pointerLockElement Property
The document.pointerLockElement
property returns the element set as the target for mouse events while the pointer is locked.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<input onkeyup="myLockElement()" onfocus="myFunction()" type="text">
<script>
var inp = document.getElementsByTagName("input")[0];
function myFunction(){
if(document.pointerLockElement == null)
inp.requestPointerLock();
}
function myLockElement(){
console.log(document.pointerLockElement);
}
</script>
</body>
</html>
Syntax
document.pointerLockElement
Return Values
Value | Explanation |
---|---|
Object | Returns the element set as the target for mouse events while the pointer is locked. |
null | If the pointer is unlocked, lock is pending, or the target is in another document. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.