---
name: "poll_keyboard"
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/poll_keyboard"
---

# poll\_keyboard(3alleg)

Polls the keyboard. Allegro game programming library.

## NAME

poll\_keyboard - Polls the keyboard. Allegro game programming library.

## SYNOPSIS

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

**int poll\_keyboard();**

## DESCRIPTION

Wherever possible, Allegro will read the keyboard input asynchronously  (ie. from inside an interrupt handler), but on some platforms that may  not be possible, in which case you must call this routine at regular  intervals to update the keyboard state variables.

To help you test your keyboard polling code even if you are programming on a platform that doesn't require it, after the first time that you call this function Allegro will switch into polling mode, so from that point onwards you will have to call this routine in order to get any keyboard input at all, regardless of whether the current driver actually needs to be polled or not.

The keypressed(), readkey(), and ureadkey() functions call poll\_keyboard() automatically, so you only need to use this function when accessing the key\[\] array and key\_shifts variable.

## RETURN VALUE

Returns zero on success, or a negative number on failure (ie. no keyboard driver installed).

## SEE ALSO

[**keyboard\_needs\_poll**(3alleg)](/keyboard_needs_poll/3alleg.md), [**install\_keyboard**(3alleg)](/install_keyboard/3alleg.md), [**key**(3alleg)](/key/3alleg.md), [**key\_shifts**(3alleg)](/key_shifts/3alleg.md), [**excamera**(3alleg)](/excamera/3alleg.md), [**exsample**(3alleg)](/exsample/3alleg.md), [**exstars**(3alleg)](/exstars/3alleg.md)
