TERMKEY_STRFKEY(3)
π TERMKEY_STRFKEY(3) π
okay bestie, welcome to the Library Functions Manual β¨ this is the page for termkey_strfkey, and yes we're gonna make a key event look cute in a string. sit down, hydrate, let's go π«Ά
πΈ NAME πΈ
termkey_strfkey β turn a key event into a string, basically glam it up for humans π
π SYNOPSIS π
#include <termkey.h>
size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len,
TermKeyKey *key, TermKeyFormat format);
Link with -ltermkey.
π¦ DESCRIPTION π¦
so termkey_strfkey() formats a string buffer so it holds a human-readable representation of a key event. it fills that buffer in a way that's analogous to the standard library besties snprintf(3) or strftime(3) β same energy, different job π«
ngl this function used to be called termkey_snprint_key() but it got renamed after version 0.6. glow-up era, we love to see it π
the format argument is what decides how the output looks, and it's a bitmask</> of these constants:
β¨ the format bits β¨
TERMKEY_FORMAT_LONGMODβ print the full modifier names, like"Shift-", instead of abbreviating them down to"S-". no more cryptic little letters πTERMKEY_FORMAT_CARETCTRLβ if the only modifier isTERMKEY_MOD_CTRLon a plain letter, render it like"^X"instead of"Ctrl-X". caret-core πTERMKEY_FORMAT_ALTISMETAβ use the name"Meta"or the letter"M"instead of"Alt"or"A". branding choice, honestly β¨TERMKEY_FORMAT_WRAPBRACKETβ if the key event is a special key rather than unmodified Unicode, wrap it up in<brackets>. cozy π§£TERMKEY_FORMAT_SPACEMODβ use spaces instead of hyphens to separate the modifier name(s) from the base key name. breathing room, periodt π¬οΈTERMKEY_FORMAT_LOWERMODβ lowercase for the modifier name. soft launch πTERMKEY_FORMAT_LOWERSPACEβ lowercase with spaces in for the key name instead of camelCase (like"page down"instead of"PageDown"). it's giving lowercase supremacy πTERMKEY_FORMAT_MOUSE_POSβ if the event is a mouse event, include the position, rendered as"@ (col,line)". rat girlies stay winning π
and for the common combos, there's shortcuts so you don't have to assemble the bitmask yourself:
TERMKEY_FORMAT_VIMβ shortcut that setsALTISMETAandWRAPBRACKET, giving you output close to the format the vim editor uses. vim girlies, this one's for you πTERMKEY_FORMAT_URWIDβ shortcut that setsALTISMETA,LONGMOD,LOWERMOD,SPACEMODandLOWERSPACE, giving you output close to the format the urwid python library uses. python besties rise π
okay important detail, don't skip it: when formatting aTERMKEY_TYPE_UNICODEkey structure, this function uses theutf8member. if that member contains an empty string (i.e. its first character is0) then this member will be prefilled by the function from thecode.numbermember. lowkey convenient when you're constructing the key structure programmatically in your own user code π οΈβ¨
π₯ RETURN VALUE π₯
termkey_strfkey() returns the number of characters written to buffer. that's it, that's the number π«
π SEE ALSO π
termkey_new(3), termkey_getkey(3), termkey_waitkey(3), termkey_get_keyname(3), termkey_strpkey(3), termkey(7)
and that's the whole page bestie!! this one came from the TERMKEY_STRFKEY(3) page in the Library Functions Manual, and you made it all the way to the end, which is iconic behavior honestly ππ go format some keys, mwah π«Άβ¨
π¦ where this page comes from
- alpine 3.24: libtermkey-doc 0.22-r4 Β· MIT
- debian trixie: libtermkey-dev 0.22-2+b1 Β· MIT
- epel 10: libtermkey-devel 0.22-2.el10_0 Β· MIT
- epel 9: libtermkey-devel 0.22-2.el9 Β· MIT
- fedora 43: libtermkey-devel 0.22-11.fc43 Β· MIT
- fedora 43: libtermkey-devel 0.22-11.fc43 Β· MIT
- fedora 44: libtermkey-devel 0.22-12.fc44 Β· MIT
- fedora 44: libtermkey-devel 0.22-12.fc44 Β· MIT
- nixos 26.05: libtermkey 0.22
- nixpkgs unstable: libtermkey 0.22
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- opensuse-leap 16.0: libtermkey-devel 0.22-bp160.1.11 Β· MIT
- ubuntu questing: libtermkey-dev 0.22-2
- ubuntu resolute: libtermkey-dev 0.22-2build1 Β· MIT
- ubuntu stonking: libtermkey-dev 0.22-3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms