q5play
    Preparing search index...

    Function pointerLock

    • 🖲 Requests that the pointer be locked to the document body, hiding the cursor and allowing for unlimited movement.

      Operating systems enable mouse acceleration by default, which is useful when you sometimes want slow precise movement (think about you might use a graphics package), but also want to move great distances with a faster mouse movement (think about scrolling, and selecting several files). For some games however, raw mouse input data is preferred for controlling camera rotation — where the same distance movement, fast or slow, results in the same rotation.

      To exit pointer lock mode, call document.exitPointerLock().

      Parameters

      • unadjustedMovement: boolean

        set to true to disable OS-level mouse acceleration and access raw mouse input

      Returns void

      q5.draw = function () {
      circle(mouseX / 10, mouseY / 10, 10);
      };

      q5.doubleClicked = function () {
      if (!document.pointerLockElement) {
      pointerLock();
      } else {
      document.exitPointerLock();
      }
      };