jspointerlock

1.0.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i jspointerlock

    Weekly Downloads

    11

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • ardean