---
name: "termkey_keyname2sym"
section: "3"
platform: "linux"
package: "libtermkey-dev"
version: "0.22-2+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/termkey_keyname2sym"
---

# termkey\_keyname2sym(3)

look up a symbolic key value for a string name

## NAME

termkey\_keyname2sym - look up a symbolic key value for a string name

## SYNOPSIS

```
#include <termkey.h>

TermKeySym termkey_keyname2sym(TermKey *tk, const char *keyname);
```

Link with *-ltermkey*.

## DESCRIPTION

**termkey\_keyname2sym**() looks up the symbolic key value represented by the given string name. This is a case-sensitive comparison. If the given name is not found, **TERMKEY\_SYM\_UNKNOWN** is returned instead. This function is the inverse of [**termkey\_get\_keyname**(3)](/termkey_get_keyname/3.md), and is a more specific form of [**termkey\_lookup\_keyname**(3)](/termkey_lookup_keyname/3.md) which only recognises names as complete strings.

Because the key names are stored in an array indexed by the symbol number, this function has to perform a linear search of the names. Use of this function should be restricted to converting key names into symbolic values during a program's initialisation, so that efficient comparisons can be done while it is running.

## RETURN VALUE

**termkey\_keyname2sym**() returns a symbolic key constant, or **TERMKEY\_SYM\_UNKNOWN**.

## SEE ALSO

[**termkey\_get\_keyname**(3)](/termkey_get_keyname/3.md), [**termkey\_lookup\_keyname**(3)](/termkey_lookup_keyname/3.md), [**termkey\_strpkey**(3)](/termkey_strpkey/3.md), [**termkey**(7)](/termkey/7.md)
