---
title: "withKeysDown"
description: "Executes the keyboard sequence specified in the given [block], whilst holding down the each of
the given [keys]. Each of the [keys] will be pressed down and released simultaneously. These keys
must not be used within the [block].

If any of the given [keys] are already down, an [IllegalStateException] will be thrown."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun KeyInjectionScope.withKeysDown(keys: List<Key>, block: KeyInjectionScope.() -> Unit)
```


Executes the keyboard sequence specified in the given `block`, whilst holding down the each of
the given `keys`. Each of the `keys` will be pressed down and released simultaneously. These keys
must not be used within the `block`.

If any of the given `keys` are already down, an `IllegalStateException` will be thrown.

#### Parameters

| | |
| --- | --- |
| keys | List of keys to be held down during injection of the `block`. |
| block | Sequence of KeyInjectionScope methods to be injected with the given keys down. |




