---
name: "termkey_interpret_mouse"
section: "3"
platform: "linux"
package: "libtermkey-dev"
version: "0.22-2+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/termkey_interpret_mouse"
---

# termkey\_interpret\_mouse(3)

interpret opaque mouse event data

## NAME

termkey\_interpret\_mouse - interpret opaque mouse event data

## SYNOPSIS

```
#include <termkey.h>

TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key,
    TermKeyMouseEvent *ev, int *button, int *line, int *col);
```

Link with *-ltermkey*.

## DESCRIPTION

**termkey\_interpret\_mouse**() fills in variables in the passed pointers according to the mouse event found in *key*. It should be called if [**termkey\_getkey**(3)](/termkey_getkey/3.md) or similar have returned a key event with the type of **TERMKEY\_TYPE\_MOUSE**.

Any pointer may instead be given as **NULL** to not return that value.

The *ev* variable will take one of the following values:

- **TERMKEY\_MOUSE\_UNKNOWN**

  an unknown mouse event.

- **TERMKEY\_MOUSE\_PRESS**

  a mouse button was pressed; *button* will contain its number.

- **TERMKEY\_MOUSE\_DRAG**

  the mouse was moved while holding a button; *button* will contain its number.

- **TERMKEY\_MOUSE\_RELEASE**

  a mouse button was released, or the mouse was moved while no button was pressed. If known, *button* will contain the number of the button released. Not all terminals can report this, so it may be 0 instead.

The *line* and *col* variables will be filled in with the mouse position, indexed from 1. Note that due to the limited number of bytes in the **TermKeyKey** structure, the line and column numbers are limited to 2047 and 4095 respectively.

## RETURN VALUE

If passed a *key* event of the type **TERMKEY\_TYPE\_MOUSE**, this function will return **TERMKEY\_RES\_KEY** and will affect the variables whose pointers were passed in, as described above.

For other event types it will return **TERMKEY\_RES\_NONE**, and its effects on any variables whose pointers were passed in, are undefined.

## SEE ALSO

[**termkey\_waitkey**(3)](/termkey_waitkey/3.md), [**termkey\_getkey**(3)](/termkey_getkey/3.md), [**termkey**(7)](/termkey/7.md)
