---
name: "simulate_keypress"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/simulate_keypress"
---

# simulate\_keypress(3alleg)

Stuffs a key into the keyboard buffer. Allegro game programming library.

## NAME

simulate\_keypress - Stuffs a key into the keyboard buffer. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**void simulate\_keypress(int key);**

## DESCRIPTION

Stuffs a key into the keyboard buffer, just as if the user had pressed  it. The parameter is in the same format returned by readkey(). Example:

```
   simulate_keypress(KEY_SPACE << 8);
   if (readkey() == (KEY_SPACE << 8))
      allegro_message("You simulated Alt+Space\n");
```

## SEE ALSO

[**install\_keyboard**(3alleg)](/install_keyboard/3alleg.md), [**simulate\_ukeypress**(3alleg)](/simulate_ukeypress/3alleg.md), [**keypressed**(3alleg)](/keypressed/3alleg.md), [**readkey**(3alleg)](/readkey/3alleg.md)
