---
name: "BRLAPI_ETCKEYFILE"
section: "3"
platform: "linux"
package: "libbrlapi-dev"
version: "3.4.1-4"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/brlapi_keys"
---

# BRLAPI\_ETCKEYFILE(3)

How to read key presses from the braille terminal.

Part of [brlapi\_keys(3)](/brlapi_keys/3.md).

## NAME

Reading key presses - How to read key presses from the braille terminal.

### Data Structures

struct **brlapi\_keybinding\_t**\
 *Key binding structure.*

### Defines

\#define **BRL\_KEYBUF\_SIZE**   256\
 \#define **BRL\_KEYCODE\_MAX**   ((**brl\_keycode\_t**) (UINT32\_MAX))\
 \#define **BRLAPI\_HOMEKEYDIR**   '.brlkeys'\
 \#define **BRLAPI\_HOMEKEYEXT**   '.kbd'\
 \#define **BRLAPI\_ETCKEYFILE**   'brlkeys'\

### Typedefs

typedef uint32\_t **brl\_keycode\_t**\

### Functions

int **brlapi\_readKey** (int block, **brl\_keycode\_t** \*code)\
 int **brlapi\_readCommand** (int block, **brl\_keycode\_t** \*code)\
 int **brlapi\_readBinding** (int block, const char \*\*code)\
 int **brlapi\_ignoreKeys** (**brl\_keycode\_t** x, **brl\_keycode\_t** y)\
 int **brlapi\_unignoreKeys** (**brl\_keycode\_t** x, **brl\_keycode\_t** y)\

## Detailed Description

Once **brlapi\_getTty()** is called, the application can call **brlapi\_readKey()**, **brlapi\_readCommand()** or **brlapi\_readBinding()** to read key presses. Not everyone can be called, it depends on parameters given to **brlapi\_getTty()**.

key presses are buffered, so that calling **brlapi\_readKey()** in non-blocking mode from times to times should suffice.

## Define Documentation

### #define BRL\_KEYBUF\_SIZE 256

buffer size

key presses won't be lost provided no more than BRL\_KEYBUF\_SIZE key presses are done between two calls to brlapi\_read\* if a call to another function is done in the meanwhile (which needs somewhere to put them before being able to get responses from the server)

### #define BRL\_KEYCODE\_MAX ((brl\_keycode\_t) (UINT32\_MAX))

brl\_keycode\_t's biggest value

As defined in `<inttypes.h>`

### #define BRLAPI\_ETCKEYFILE 'brlkeys'

Prefix for driver-dependent key names header files

Driver-dependent key names header files are stored in BRLAPI\_ETCDIR/BRLAPI\_ETCKEYFILE-xy.h where `xy` is the driver code, as returned by **brlapi\_getDriverId()**

### #define BRLAPI\_HOMEKEYDIR '.brlkeys'

*BrlAPI* 's $HOME settings directory

this directory will contain per-user configuration

### #define BRLAPI\_HOMEKEYEXT '.kbd'

*BrlAPI* 's key binding suffix

## Typedef Documentation

### typedef uint32\_t brl\_keycode\_t

type for key codes

Its size is 32 bits, so driver implementors have to restrict themselves to a 32 bit space.

## Function Documentation

### int brlapi\_ignoreKeys (brl\_keycode\_t x, brl\_keycode\_t y)

Ignore some key presses from the braille keyboard

This function asks the server to give keys between x and y to *brltty*, rather than returning them to the application via brlapi\_read(Key\|Command\|Binding)()

**Note:**

The given codes are either raw keycodes if BRLKEYCODES was given to **brlapi\_getTty()**, or *brltty* commands if BRLCOMMANDS was given.

### int brlapi\_readBinding (int block, const char \*\* code)

read a key binding from the braille keyboard

This function returns a command name, as bound in user's configuration file: if the read is successful, a pointer on a string is returned, this is the string defined in $HOME/.brlkeys/appli-xy.kbd for the key which was read, else `NULL` is returned

**Parameters:**

*block* tells whether the call should block until a key is pressed (1) or should only probe key presses (0). \
 *code* holds the key string if a key press is indeed read.

It can be called only if a **brlapi\_keybinding\_t** structure was filled and given to **brlapi\_getTty()**

**Returns:**

\-1 on error and \*code is then undefined, 0 if block was 0 and no key was pressed so far, or 1 and \*code holds the key string.

### int brlapi\_readCommand (int block, brl\_keycode\_t \* code)

Read a command from the braille keyboard

This function returns *brltty* commands, as described in `<brltty/brldefs`.h\> . These are hence pretty driver-independent, and should be used by default when no other option is possible.

It can be called only if BRLCOMMANDS was given to **brlapi\_getTty()**

By default, all commands but those which restart drivers and switch virtual terminals are returned to the application and not to brltty. If the application doesn't want to see some command events, it should call **brlapi\_ignoreKeys()**

**Parameters:**

*block* tells whether the call should block until a key is pressed (1) or should only probe key presses (0). \
 *code* holds the command code if a key press is indeed read.

**Returns:**

\-1 on error and \*code is then undefined, 0 if block was 0 and no key was pressed so far, or 1 and \*code holds the command code.

### int brlapi\_readKey (int block, brl\_keycode\_t \* code)

Read a key from the braille keyboard

This function returns raw keycodes, as specified by the terminal driver. It generally corresponds to the code the terminal tells to the driver.

This should only be used to application which are dedicated to a particular braille terminal. Hence, checking the terminal type thanks to a call to **brlapi\_getDriverId()** or even **brlapi\_getDriverName()** before getting tty control is a pretty good idea.

It can be called only if BRLKEYCODES was given to **brlapi\_getTty()**

By default, all the keypresses will be passed to the client, none will go through brltty, so the application will have to handle console switching itself.

**Parameters:**

*block* tells whether the call should block until a key is pressed (1) or should only probe key presses (0), \
 *code* holds the key code if a key press is indeed read.

**Returns:**

\-1 on error and \*code is then undefined, 0 if block was 0 and no key was pressed so far, or 1 and \*code holds the key code.

### int brlapi\_unignoreKeys (brl\_keycode\_t x, brl\_keycode\_t y)

Unignore some key presses from the braille keyboard

This function asks the server to return keys between x and y to the application, and not give them to *brltty*.

**Note:**

You shouldn't ask the server to give you key presses which are usually used to switch between TTYs, unless you really know what you are doing !

The given codes are either raw keycodes if BRLKEYCODES was given to **brlapi\_getTty()**, or *brltty* commands if BRLCOMMANDS was given.
