keybound(3NCURSES)
π keybound β get definition of a curses function key code π
okay bestie, so you know how keybound(3NCURSES) lives in the Library calls section of the ncurses fam? yeah. that one. let's get into it β¨
πΈ SYNOPSIS πΈ
#include <curses.h>
char * keybound(int key-code, int count);
β¨ DESCRIPTION β¨
so keybound is an ncurses extension (yes, an extension, hold that thought for PORTABILITY, bestie) and what it does is let a curses application get the value of the string that's bound to the function key key-code. if you wanna see where those bindings actually get used on input, go peek at wgetch(3NCURSES) β and if you're on the wide-character API side of things, that's wget_wch(3NCURSES) for you π
by default, those bindings are string capabilities pulled from the terminfo database entry that matches your terminal type. iconic. classic. the standard behavior, no notes.
now here's the fun part: your app can override those definitions using define_key(3NCURSES) β and it's non-destructive and repeatable, like literally you can just keep doing it, because it's as if you're pushing new definitions onto a stack. stack energy. very LIFO of it π«Ά
and that's where the count parameter comes in, because it lets you reach into that stack and grab the *n*th most recently defined binding. and if you pass 0? that selects the binding that actually gets used on input. the one that matters. the main character π
π RETURN VALUE π
if key-code matches a function key that's been defined by the application or the terminal type currently in use, then keybound will allocate and hand you back a string. and heads up β you, the application, have to free it. that's on you, bestie, don't forget π
keybound returns NULL if key-code is not positive, or if it doesn't correspond to a key code definition at all. no binding, no string, that's it.
π¦ EXTENSIONS π¦
keybound is an ncurses extension. periodt. π
π PORTABILITY π
if your application is out here using ncurses extensions, you should condition their use on the visibility of the NCURSES_VERSION preprocessor macro. basically: vibe check the macro before you commit, so your code doesn't get humbled on a system that isn't ncurses. iykyk π₯
π AUTHORS π
Thomas Dickey
π SEE ALSO π
ncurses(3NCURSES)define_key(3NCURSES)keyok(3NCURSES)key_defined(3NCURSES)terminfo(5)
and that's the whole page, bestie β no crumbs left π this was ncurses 6.6, dated 2024-12-28, and honestly? she ate. go bind some keys πβ¨π
π¦ where this page comes from
- ubuntu resolute: ncurses-doc 6.6+20251231-1 Β· MIT/X11
- ubuntu stonking: ncurses-doc 6.6+20260608-2 Β· MIT/X11
- Copyright 2018-2023,2024 Thomas E. Dickey
- Copyright 1999-2008,2010 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms