Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.74 KB

README.md

File metadata and controls

64 lines (47 loc) · 1.74 KB

jsPointerLock

NPM Version NPM Downloads License

W3C Pointer Lock Fallback

Specification

Pointer Lock API, W3C

Usage

I suggest you to use jspm as your package manager.

import PointerLock from "jspointerlock";

const pointerLock = new PointerLock(document.body);

pointerLock.on("change", (isLocked) => {
  console.log(`pointer is ${isLocked ? 'locked' : 'not locked'}`);
});

pointerLock.element.addEventListener("click", () => {
  pointerLock.requestPointerLock();
});

Directly in a browser

Please checkout the index-dist.html file for direct usage in a browser.

API

Classes

  • PointerLock
    • Constructor(Element element) extends EventEmitter
    • Members
      • requestPointerLock() => Void
    • Static Members
      • exitPointerLock() => Void
    • Properties
      • element => Element
      • isLocked => Boolean
    • Static Properties
      • isSupported => Boolean
      • pointerLockElement => Element
    • Events
      • change => (Boolean isLocked, Event e)
      • error => (Error err, Event e)
      • unsupported => ()

License

MIT