##### Views

- Page
- Discussion
- View source
- History

# love.mouse.setPosition

Sets the current position of the mouse.

## Function

### Synopsis

love.mouse.setPosition( x, y )

### Arguments

`number x`
  The new position of the mouse along the x-axis.
`number y`
  The new position of the mouse along the y-axis.

### Returns

Nothing.

## Examples

Snap the mouse to a new X position when the user presses a number key. The Y position is unchanged thanks to love.mouse.getY.

function love.keypressed(key)
if tonumber(key) then -- if the key is numeric (0-9), execute the next line
love.mouse.setPosition(tonumber(key) * 10, love.mouse.getY()) -- multiply the key by 10 to make the effect more visible, maintain the Y position via getY
end
end

## See Also

- love.mouse
- love.mouse.getPosition
- love.mouse.getX
- love.mouse.getY

## Other Languages

Dansk – Deutsch – English – Español – Français – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Polski – Português – Română – Slovenský – Suomi – Svenska – Türkçe – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – ไทย – 日本語 – 正體中文 – 简体中文 – Tiếng Việt – 한국어
More info

Retrieved from "https://www.love2d.org/wiki/love.mouse.setPosition"
Categories: Templates | Functions

##### Personal tools

- Log in

##### Search

##### Toolbox

- What links here
- Related changes
- Special pages
- Printable version
- Permanent link
- Browse properties