---
name: "up.event.inputDevice"
area: "API"
kind: "JavaScript property"
parent: "up.event module"
visibility: "experimental"
url: "https://unpoly.com/api/up.event.inputDevice"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.event module](https://unpoly.com/api/up.event.md)</nav>

# up.event.inputDevice

**This feature is experimental**. Please [share](https://github.com/unpoly/unpoly/discussions) your experiences so we know what to keep or change.

The class of input device used to cause the current event.

It can assume one of the following values:

| Value | Meaning |
| --- | --- |
| `'key'` | The event was caused by a keyboard interaction. |
| `'pointer'` | The event was caused by an interaction via mouse, touch or stylus. |
| `'unknown'` | The input device is unknown or this event was not caused by user input. |

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Limitations](#limitations)
- [Value](#value)

</nav>

## Example {#example}

In event listeners, `up.event.inputDevice` returns the type of input device that caused the event:

```js
document.addEventListener('mousedown', function() {
  console.log(up.event.inputDevice) // will print "pointer"
})

document.addEventListener('keydown', function() {
  console.log(up.event.inputDevice) // will print "key"
})

document.addEventListener('click', function() {
  // will print either "pointer" or "key", depending on
  // whether the link was activated with mouse or keyboard
  console.log(up.event.inputDevice)
})
```

## Limitations {#limitations}

Unpoly can only detect the input device when the user interacts with the document area. Interactions with browser-drawn UI elements (like the back button or scroll bar) cannot be detected:

```js
window.addEventListener('scroll', function() {
  console.log(up.event.inputDevice) // will print "unknown"
})
```

---

## Value {#value}

### inputDevice {#inputDevice}

A string describing the current input device class.

Type: string

