---
name: "keyboard_seteventhandler"
section: "3vga"
platform: "linux"
package: "svgalibg1-dev"
version: "1:1.4.3-7"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/keyboard_seteventhandler/3vga"
---

# keyboard\_seteventhandler(3vga)

define an event handler for keyboard events in raw mode

## NAME

keyboard\_seteventhandler, keyboard\_setdefaulteventhandler - define an event handler for keyboard events in raw mode

## SYNOPSIS

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

**typedef void (\****\_\_keyboard\_handler***) (int** *scancode***, int** *press***);**

**void keyboard\_seteventhandler(\_\_keyboard\_handler** *handler***);**\
 **void keyboard\_setdefaulteventhandler(void);**

## DESCRIPTION

These functions allow to define a keyboard event handler which is called by [**keyboard\_update**(3)](/keyboard_update/3.md) and  [**keyboard\_waitforupdate**(3)](/keyboard_waitforupdate/3.md) when a keyboard event occured.

*press* is **KEY\_EVENTRELEASE** or **KEY\_EVENTPRESS** if key *scancode* was released or pressed. Actually the first value is 0 and the second is 1 which are so intuitive s.t. you may use them in your program.

Even you specify an own handler, svgalib will check for **\<Alt\>-F\*** or **\<Ctrl\>-C** for console switches or generation of **SIGINT** if allowed by [**keyboard\_translatekeys**(3)](/keyboard_translatekeys/3.md).

Calling **keyboard\_setdefaulteventhandler()** reinstates the default handler which maintains the tables used by [**keyboard\_getstate**(3)](/keyboard_getstate/3.md) and  [**keyboard\_keypressed**(3)](/keyboard_keypressed/3.md). It is probably a good idea to call [**keyboard\_clearstate**(3)](/keyboard_clearstate/3.md) after reenabling the default handler.

Here are the supported scancodes. The names of the **#defines** originate from the US keyboard layout, for other countries, they'll refer to the key in the same physical location, but the keycap will have a different inscription. For the list below, add **SCANCODE\_** in front of the names to get the right name for your C source. That means, if it lists **BACKSLASH** below, you shall use **SCANCODE\_BACKSLASH** as symbol in your program. In addition to the names below we also have **SCANCODE\_0** - **SCANCODE\_9**,  **SCANCODE\_KEYPAD0** - **SCANCODE\_KEYPAD9**,  **SCANCODE\_A** - **SCANCODE\_Z**, and  **SCANCODE\_F1** - **SCANCODE\_F12**.

The other key names are **ESCAPE**,  **MINUS**,  **EQUAL**,  **BACKSPACE**,  **TAB**,  **BRACKET\_LEFT**,  **BRACKET\_RIGHT**,  **ENTER**,  **LEFTCONTROL**,  **SEMICOLON**,  **APOSTROPHE**,  **GRAVE**,  **LEFTSHIFT**,  **BACKSLASH**,  **COMMA**,  **PERIOD**,  **SLASH**,  **RIGHTSHIFT**,  **KEYPADMULTIPLY**,  **LEFTALT**,  **SPACE**,  **CAPSLOCK**,  **NUMLOCK**,  **SCROLLLOCK**,  **CURSORUPLEFT**,  **CURSORUP**,  **CURSORUPRIGHT**,  **KEYPADMINUS**,  **CURSORLEFT**,  **CURSORRIGHT**,  **KEYPADPLUS**,  **CURSORDOWNLEFT**,  **CURSORDOWN**,  **CURSORDOWNRIGHT**,  **KEYPADPERIOD**,  **LESS**,  **KEYPADENTER**,  **RIGHTCONTROL**,  **CONTROL**,  **KEYPADDIVIDE**,  **PRINTSCREEN**,  **RIGHTALT**,  **BREAK**,  **BREAK\_ALTERNATIVE**,  **HOME**,  **CURSORBLOCKUP**,  **PAGEUP**,  **CURSORBLOCKLEFT**,  **CURSORBLOCKRIGHT**,  **END**,  **CURSORBLOCKDOWN**,  **PAGEDOWN**,  **INSERT**, and  **REMOVE**.

## SEE ALSO

[**svgalib**(7)](/svgalib/7.md), [**vgagl**(7)](/vgagl/7.md), [**libvga.config**(5)](/libvga.config/5.md), **keytest**(6), **eventtest**(6), [**keyboard\_init**(3)](/keyboard_init/3.md), [**keyboard\_init\_return\_fd**(3)](/keyboard_init_return_fd/3.md), [**keyboard\_close**(3)](/keyboard_close/3.md), [**keyboard\_getstate**(3)](/keyboard_getstate/3.md), [**keyboard\_keypressed**(3)](/keyboard_keypressed/3.md), [**keyboard\_clearstate**(3)](/keyboard_clearstate/3.md), [**keyboard\_translatekeys**(3)](/keyboard_translatekeys/3.md), [**keyboard\_update**(3)](/keyboard_update/3.md), [**keyboard\_waitforupdate**(3)](/keyboard_waitforupdate/3.md), [**vga\_waitevent**(3)](/vga_waitevent/3.md)

## AUTHOR

This manual page was edited by Michael Weller \<eowmob@exp-math.uni-essen.de\>. The exact source of the referenced function as well as of the original documentation is unknown.

It is very likely that both are at least to some extent are due to Harm Hanemaayer \<H.Hanemaayer@inter.nl.net\>.

Occasionally this might be wrong. I hereby asked to be excused by the original author and will happily accept any additions or corrections to this first version of the svgalib manual.
