##### Views

- Page
- Discussion
- View source
- History

# love.mousepressed

Callback function triggered when a mouse button is pressed.

## Function

### Synopsis

love.mousepressed( x, y, button )

### Arguments

`number x`
  Mouse x position.
`number y`
  Mouse y position.
`MouseConstant button`
  Mouse button pressed.

### Returns

Nothing.

## Examples

Position a string ("Text") wherever the user left-clicks.

function love.load()
printx = 0
printy = 0
end
function love.draw()
love.graphics.print("Text", printx, printy)
end
function love.mousepressed(x, y, button)
if button == "l" then
printx = x
printy = y
end
end

## See Also

- love

## 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.mousepressed"
Categories: Templates | Callbacks

##### Personal tools

- Log in

##### Search

##### Toolbox

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