---
name: "XkbGetKeyboard"
section: "3"
platform: "linux"
package: "libx11"
version: "1.8.14-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/XkbGetKeyboard"
---

# XkbGetKeyboard(3)

Retrieves one or more components of a keyboard device description

## NAME

XkbGetKeyboard -   Retrieves one or more components of a keyboard device description

## SYNOPSIS

**XkbDescPtr XkbGetKeyboard** **(Display \****display***,** **unsigned int** *which***,** **unsigned int** *device\_spec***);**

## ARGUMENTS

- *display*

  connection to the X server

- *device\_spec*

  device ID, or XkbUseCoreKbd

- *bits\_to\_change*

  determines events to be selected / deselected

- *values\_for\_bits*

  1=\>select, 0-\>deselect; for events in bits\_to\_change

## DESCRIPTION

**XkbGetKeyboard** allocates and returns a pointer to a keyboard description. It queries the server for those components specified in the *which* parameter for device *device\_spec* and copies the results to the XkbDescRec it allocated. The remaining fields in the keyboard description are set to NULL. The valid masks for *which* are those listed in Table 1.

| | | |
| --- | --- | --- |
| Table 1 Mask Bits for XkbDescRec |
| Mask Bit | XkbDescRec Field | Value |
| XkbControlsMask | ctrls | (1L\<\<0) |
| XkbServerMapMask | server | (1L\<\<1) |
| XkbIClientMapMask | map | (1L\<\<2) |
| XkbIndicatorMapMask | indicators | (1L\<\<3) |
| XkbNamesMask | names | (1L\<\<4) |
| XkbCompatMapMask | compat | (1L\<\<5) |
| XkbGeometryMask | geom | (1L\<\<6) |
| XkbAllComponentsMask | All Fields | (1L\<\<7) |

**XkbGetKeyboard** is used to read the current description for one or more components of a keyboard device. It calls [**XkbGetKeyboardByName**(3)](/XkbGetKeyboardByName/3.md) as follows:

*XkbGetKeyboardByName(dpy, device\_spec,* NULL, *which, which,* False).

If successful, **XkbGetKeyboard** returns a pointer to a newly allocated **XkbDescRec** structure, which is described in [**XkbGetKeyboardByName**(3)](/XkbGetKeyboardByName/3.md), and which should be freed with [**XkbFreeKeyboard**(3)](/XkbFreeKeyboard/3.md). If **XkbGetKeyboard** does not succeed, it returns **NULL**.

## DIAGNOSTICS

- BadAlloc

  Unable to allocate storage

## SEE ALSO

[**XkbGetKeyboardByName**(3)](/XkbGetKeyboardByName/3.md)
