Skip to content

Obtain raw mouse input with pointer lock #2135

Description

@DNin01

Most operating systems enable a feature known as mouse acceleration, which ramps up the speed of your cursor the faster you move your mouse. This basically means your cursor will be less sensitive to slower mouse movements and more sensitive to faster mouse movements. This is fine for most tasks that use a mouse cursor but is not the best fit for controlling 3D cameras (e.g., in first-person games). For gaming, non-accelerated input is generally preferred because then the camera moves exactly as your mouse does.

Chrome supports PointerLockOptions.unadjustedMovement to ignore mouse acceleration.

element.requestPointerLock({
  unadjustedMovement: true
});
Pointer Lock blocks

This could easily be integrated into the Pointer Lock extension. Obviously, this could be controlled by the project creator using a block. Here's a wording I came up with to make it as intuitive as possible for anyone who has never heard of this terminology before:

  • "Exact movement" means raw input is obtained directly from the mouse, bypassing modifiers from sensitivity and mouse acceleration settings.
    • This works best for 3D camera rotation and is the default option.
  • "Cursor (absolute)" obtains mouse input from the OS, which may be adjusted by sensitivity and mouse acceleration settings.
    • This works best for most computation tasks.
  • "Cursor (scaled)" obtains mouse input from the OS and then multiplies it by the project player's pixel density (measuring as if you were moving your cursor across the entire stage).
    • This works best for moving objects on a canvas or workspace, since the amount of movement will be based on the size of the player screen.

This might be overthinking it and making it even more complex for some people, though; just a block to enable or disable raw input would be fine.

Activity

  1. Brackets-Coder commented on May 30, 2025

    @Brackets-Coder
    Member

    might be helpful

  2. Xeltalliv commented on Jun 4, 2025

    @Xeltalliv
    Contributor

    Chrome supports PointerLockOptions.unadjustedMovement to ignore mouse acceleration.

    Not everywhere. I have developed a dislike for unadjustedMovement: true, because of how often it's implemented incorrectly. It's not supported for me and makes requestPointerLock throw an exception. I've come across plenty of websites that do not handle it correctly, and as such become unusable, unless I manually modify them. Websites that handle it correctly first try with it, and then if that fails - without it.

    Image

  3. DNin01 commented on Jun 4, 2025

    @DNin01
    CollaboratorAuthor

    MDN Web Docs says it's not supported on Linux, but that might not be the only issue.

    Good to know that a fallback may be necessary.

  4. SharkPool-SP commented on Jul 21, 2026

    @SharkPool-SP
    Collaborator

    Technically hyper sense V2 can do this when merged?:

    Image
  5. SharkPool-SP commented on Jul 21, 2026

    @SharkPool-SP
    Collaborator

    Just as a thought for later. No need for that chrome-only api

  6. GarboMuffin commented on Jul 25, 2026

    @GarboMuffin
    Member

    That's not the same thing at all? The issue is about getting unaccelerated movement values from the browser. Not about processing those values in various different ways.

  7. SharkPool-SP commented on Jul 25, 2026

    @SharkPool-SP
    Collaborator

    I'm a bit confused then on what the values should be

  8. GarboMuffin commented on Jul 25, 2026

    @GarboMuffin
    Member

    I think the original issue description is very detailed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions