<!-- Page: https://rustic-game-engine.pages.dev/docs/api/input/any-key-pressed -->

# rustic.any_key_pressed()

[Input](https://rustic-game-engine.pages.dev/markdown/api/input.md)

## Compatibility

**Supported languages:** C, C++, C#, Python, JavaScript, Lua 5.4, Luau, Java, PHP and HTML/inline JavaScript (binding spellings and return shapes differ).

Use a compatible native engine build and the language tools required by your binding. This does not establish browser/mobile export or release qualification for every OS.

The signature below is the shared reference notation; language examples show the actual binding syntax. Question marks mark optional arguments and explicit defaults are shown where recorded. Do not copy reference notation as a typed declaration.

See [Feature status and compatibility](https://rustic-game-engine.pages.dev/markdown/reference/compatibility.md) for API 1.0/1.1 and per-method restrictions. Engine release tags and Docs v0.1 are independent versions.

## Signature

`rustic.any_key_pressed()`

## Setup and usage

For movement, read `rustic.key(name).held` in `FixedUpdate`. Hover or click the Play viewport first. This build forwards WASD, arrow keys, and Shift only. Named actions and press/release events are not connected yet.

## Parameters

This call has no arguments.

## Return and timing

Key reads return `{ pressed, released, held, axis }`. Only `held` and `axis` are populated for forwarded keys; pressed/released stay false, key events stay empty, and any-key stays false.

## Execution behavior

Core write timing differs between immediate Lua host calls, deferred JavaScript/Web commands and external SDK query flushes. Scheduled actions advance with the scene clock; synchronous queries evaluate at the call. Follow [execution rules](https://rustic-game-engine.pages.dev/markdown/guides/scripting.md#when-mutations-take-effect) and the return/timing notes for this category.

## Language examples

Use these snippets inside Start/on_start after generating the Programming Workspace and attaching the script. Python imports rustic, Game and instance from rustic; C++ includes rustic.hpp; C includes rustic.h; C# uses using static Rustic; Java runs inside a Rustic subclass; PHP declares global $rustic, $Game, $instance in its callback. HTML uses an inline script in a ui/ asset. See [Lifecycle callbacks](https://rustic-game-engine.pages.dev/markdown/callbacks.md) for complete registration examples. Public-property examples require a declared integer health property. Scene examples require the named objects to exist before Play.

### Lua 5.4

```lua
if rustic.key('KeyW').held then
  print('forward key is held')
end
local action = rustic.input("Jump")
local events = rustic.key_events()
local anyPressed = rustic.any_key_pressed()
```

### JavaScript

```javascript
if (rustic.key('KeyW').held) console.debug('forward key is held');
const action = rustic.input("Jump");
const events = rustic.key_events();
const anyPressed = rustic.any_key_pressed();
```

### Python

```python
held = rustic.key("KeyW")["held"]
action = rustic.input("Jump")
events = rustic.key_events()
anyPressed = rustic.any_key_pressed()
```

### C++

```cpp
RusticActionState forward=rustic.key("KeyW");
if (forward.held) rustic.log("debug", "moving");
auto action = rustic.input("Jump");
auto events = rustic.key_events();
auto anyPressed = rustic.any_key_pressed();
```

### C#

```csharp
bool held = rustic.key("KeyW").held;
var action = rustic.input("Jump");
var events = rustic.key_events();
var anyPressed = rustic.any_key_pressed();
```

### Luau

```lua
if rustic.key('KeyW').held then rustic.log('info','moving') end
local action = rustic.input("Jump")
local events = rustic.key_events()
local anyPressed = rustic.any_key_pressed()
```

### C

```c
bool held = rustic.key("KeyW").held;
RusticActionState action = rustic.input("Jump");
RusticKeyEvents events = rustic.key_events();
bool anyPressed = rustic.any_key_pressed();
```

### Java

```java
boolean held = rustic.key("KeyW").held;
var action = rustic.input("Jump");
var events = rustic.key_events();
var anyPressed = rustic.any_key_pressed();
```

### PHP

```php
$held = $rustic->key("KeyW")["held"];
$action = $rustic->input("Jump");
$events = $rustic->key_events();
$anyPressed = $rustic->any_key_pressed();
```

### HTML / inline JS

```javascript
if (rustic.key('KeyW').held) console.debug('forward key is held');
const action = rustic.input("Jump");
const events = rustic.key_events();
const anyPressed = rustic.any_key_pressed();
```

## Shared Input constraints

- The embedded Play viewport forwards held KeyW, KeyA, KeyS, KeyD, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, ShiftLeft, and ShiftRight. It does not forward other keys or input from New Window or Standalone. Follow the [Lua controller guide](https://rustic-game-engine.pages.dev/markdown/scripting/lua/input.md) for attachment steps, a complete example, and troubleshooting.
- Every gameplay language calls the engine-owned API. Rustic supplies SDKs and dispatches callbacks; scripts do not parse requests or serialize responses. See the language guide for complete setup and callback registration.

## Errors and debugging

Read the constraints above and the Console diagnostic. Invalid types, non-finite values, stale targets or unavailable native services can fail validation. A failed callback disables the behavior; a failed source reload keeps the last good instance. Exact error messages depend on the language adapter. See [Troubleshooting](https://rustic-game-engine.pages.dev/markdown/troubleshooting.md).

## Related APIs

- [rustic.input()](https://rustic-game-engine.pages.dev/markdown/api/input/input.md)
- [rustic.key()](https://rustic-game-engine.pages.dev/markdown/api/input/key.md)
- [rustic.key_events()](https://rustic-game-engine.pages.dev/markdown/api/input/key-events.md)

[All input APIs](https://rustic-game-engine.pages.dev/markdown/api/input.md)
