key_defined(3NCURSES)
π key_defined β the ncurses girlies' guide π
okay bestie, so this is a page from Library calls in the ncurses manual, and it's literally about figuring out which function key a string is bound to. it's giving detective energy fr fr πβ¨
β¨ NAME β¨
key_defined β obtain the key code for an ncurses function key definition π
πΈ SYNOPSIS πΈ
#include <curses.h>
int key_defined(const char * definition);
that's it, that's the whole vibe. one include, one function, no cap. π
π¦ DESCRIPTION π¦
so key_defined is an ncurses extension β like, not a standard-curses thing, it's our special little bonus β and what it does is let a curses application determine the function key code, if any, to which the string definition is bound.
basically: you hand it a string, it tells you which key (if any) that string is vibing with. iconic behaviour honestly π
β RETURN VALUE β
here's the tea on what you get back:
- if definition is bound to something,
key_definedreturns the first key code to which definition is bound. first come, first served, periodt. π - if nothing is bound to it? it returns
0. like, nobody's home. π - but WAIT β if definition is a prefix of another bound definition,
key_definedreturns-1. not me getting a weird negative number because my string was only part of a bigger bound definition π careful with that one bestie.
π«Ά fr fr, remember:0means "not bound at all" and-1means "you gave me a prefix of something that IS bound." two very different moods.
π EXTENSIONS π
key_defined is an ncurses extension. it's not out here in regular curses, it's an ncurses-only situation, iykyk. β¨
π§ PORTABILITY π§
if you're using ncurses extensions in your app, you should condition their use on the visibility of the NCURSES_VERSION preprocessor macro. like, vibe check your environment first before you commit to using the fancy stuff, because other curses implementations might not have it and that would be so embarrassing for everyone involved π
π AUTHORS π
Thomas Dickey β the author, the legend, the main character. π«‘
π SEE ALSO π
ncurses(3NCURSES)define_key(3NCURSES)keybound(3NCURSES)keyok(3NCURSES)
go read those too, they're all part of the same little key-binding friend group π
and that's the whole page bestie!! this was ncurses 6.6, dated 2025-10-04, and honestly? slay. go bind some keys, you've got this π β¨π
π¦ 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-2024,2025 Thomas E. Dickey
- Copyright 2003-2006,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