# How to take control and/or remove the cursor?

**URL:** <https://discourse.processing.org/t/how-to-take-control-and-or-remove-the-cursor/11258>\
**Category:** Coding Questions\
**Created:** [May 15, 2019, 10:02am UTC](https://discourse.processing.org/t/how-to-take-control-and-or-remove-the-cursor/11258 "2019-05-15T10:02:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![2000mater](https://avatars.discourse-cdn.com/v4/letter/2/ccd318/32.png) [@2000mater](https://discourse.processing.org/u/2000mater)\
**Post date:** [May 15, 2019, 10:02am UTC](https://discourse.processing.org/t/how-to-take-control-and-or-remove-the-cursor/11258/1 "2019-05-15T10:02:32Z")

</div>

Is there a way to ‘listen to’ where the mouse wanted to move even if there is no place for it? Basically telling the program the same data the touchpad or mouse would give the device.

I’ve seen cases where the page asked for cursor control.

My goal is to create a 2D environment where the camera would spin at the corresponding direction as the mouse is moved.  
I thought one of my solutions could be making the cursor invisible with noCursor(), and at the end of every frame moving the mouse back to it’s normal place (meaning that there would be enough space for any movement and calculating the mouseXY before placing back.)

I couldn’t figure out how to do any of the listed above, so help would be very appreciated.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 16, 2019, 6:49am UTC](https://discourse.processing.org/t/how-to-take-control-and-or-remove-the-cursor/11258/2 "2019-05-16T06:49:16Z")

</div>

> [@Problem with robot cursor](https://discourse.processing.org/t/problem-with-robot-cursor/2046):
>
> Greetings everyone! i was making a program that moves the camera and lets you ovserve an object from any direction (using w, a, s, d and the mouse, kinda like a game), to do that i use the robot class to restart the position of the mouse so the borders of the window don’t act as a limitant factor, the problem is that it doesn’t respond as i was expecting (it reset the position of the camera). Here the code: import java.awt.\*; import java.awt.event.\*; Robot robot; float x, y, z; int xp = 0, yp…

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 16, 2019, 7:00am UTC](https://discourse.processing.org/t/how-to-take-control-and-or-remove-the-cursor/11258/3 "2019-05-16T07:00:05Z")

</div>

In Processing the robot class allows this

Not sure about p5js

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [May 16, 2019, 8:15am UTC](https://discourse.processing.org/t/how-to-take-control-and-or-remove-the-cursor/11258/4 "2019-05-16T08:15:11Z")

</div>

Look into the [pointer lock api](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API). It’s not integrated with p5 as far as I know and I’m not sure that all browsers support it but it’s pretty much exactly what you’re looking for.

Due to security I think you have to get the user to click before it starts working like making a browser full screen. Also it’s esc to get out of it.

I remembered seeing it in something made in three.js and I couldn’t find what I was thinking of but I did find [this demo](https://codepen.io/tembling/pen/reZjEw).
