keyok(3NCURSES)

πŸ’– keyok β€” the manual, but make it a group chat πŸ’–

okay bestie, so this is a page from the ncurses library calls section (yes, 3NCURSES, the whole vibe), and it's literally just about one little function called keyok. it lets you turn a function key code on or off. that's the whole thing. iconic behavior honestly. πŸŽ€


✨ NAME ✨

keyok β€” enable or disable an ncurses function key code πŸ¦‹


✨ SYNOPSIS ✨

#include <curses.h>

int keyok(int key-code, bool bf);

like. that's it. two args. we love a low-maintenance king. πŸ’…


✨ DESCRIPTION ✨

so keyok is an ncurses extension (more on that in a sec, bestie, don't spiral), and what it does is it lets a curses application disable a function key key-code that would otherwise come back at you from wgetch(3NCURSES).

and if you're one of the wide-character API girlies? that's wget_wch(3NCURSES) for you. same energy, different letter. 🌸

and here's the part that actually slays: key codes that have been disabled can be re-enabled. you're not dooming them forever. it's giving reversible. it's giving "we can fix her". πŸ’–

bf is the lil parameter that selects the desired enablement status β€” that's your on/off switch, your vibe check, your whole entire decision. 🫢

and the way this is more fine-grained than just calling keypad(3NCURSES)?? because keypad(3NCURSES) affects all the function keys, like a group punishment, whereas keyok lets you pick and choose. main character energy fr fr. no cap. πŸ‘‘


✨ RETURN VALUE ✨

keyok returns ERR when:

  • key-code is nonpositive 😭
  • key-code is not a recognized value πŸ’€
  • enablement of key-code is already in the desired state β€” like bestie, it's already doing that. nothing to change. πŸ™ˆ

otherwise? keyok returns OK. and we celebrate. πŸŽ‰


✨ EXTENSIONS ✨

keyok is an ncurses extension. periodt. πŸ’œ


✨ PORTABILITY ✨

okay so this is the part where we're responsible adults for one (1) second:

applications employing ncurses extensions should condition their use on the visibility of the NCURSES_VERSION preprocessor macro. like, check before you use it, bestie. be safe out there. 🌈

and the good news: NetBSD curses since 2.0 (2004) supports keyok. so it's not just an ncurses thing anymore, she's been out here since 2004. ate. ⭐


✨ AUTHORS ✨

Thomas Dickey πŸŽ€


✨ SEE ALSO ✨

  • ncurses(3NCURSES)
  • define_key(3NCURSES)
  • keybound(3NCURSES)
  • keyok(3NCURSES)
  • key_defined(3NCURSES)

(yes, keyok(3NCURSES) is in its own SEE ALSO list. she's self-referential. she contains multitudes. iykyk. πŸ’…)


and that's the whole page, bestie!! this was ncurses version 6.6, dated 2025-10-04 β€” go forth and toggle your function keys responsibly, mwah πŸ’–βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from