keyok(3X)

πŸ’– keyok(3X) β€” library calls, but make it a vibe πŸ’–

okay bestie, pull up a chair, we're talking about keyok from the curses library (section 3X, library calls, you know the drill). This is the one that lets you enable or disable an ncurses function key code, and honestly? iconic behavior. πŸŽ€


✨ NAME ✨

keyok β€” enable or disable an ncurses function key code

like. the name says it all fr fr. key. ok. key ok? key NOT ok. you decide. πŸ’…


🌸 SYNOPSIS 🌸

#include <curses.h>

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

two args, one int of return, we love a low-maintenance queen 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so the tea is: keyok is an ncurses extension, and what it does is let a curses application disable a function key key-code that would normally come back to you from wgetch(3X).

and for the wide-character girlies out there β€” that's you if you're living in wget_wch(3X) land β€” same deal, it applies to you too. πŸ’œ

now, key codes that have been disabled? they can absolutely be re-enabled. it's not a permanent situation, bestie. nothing is forever.

the bf parameter is the mood-setter here β€” it selects the desired enablement status. so bf is basically holding up the little "on/off" sign. πŸͺ§

and why is this such a slay? because this operation is more fine-grained than calling keypad(3X), which affects all function keys at once. keyok is the "i want to customize one specific thing" version. it's giving main character energy, it's giving precision, it's giving "i don't do group settings." πŸ‘‘


😭 RETURN VALUE 😭

keyok returns ERR if any of these lil situations happen:

  • key-code is nonpositive
  • key-code is not a recognized value
  • enablement of key-code is already in the desired state
not me getting an error because the thing is already exactly how i wanted it πŸ’€ the audacity. the disrespect. anyway.

Otherwise, keyok returns OK. and we love an OK. 🌈


πŸ”₯ EXTENSIONS πŸ”₯

keyok is an ncurses extension. periodt. that's the whole section. πŸ’…


🌸 PORTABILITY 🌸

if your application is out here employing ncurses extensions, you should condition their use on the visibility of the NCURSES_VERSION preprocessor macro. that's the move. don't just assume, bestie β€” check first. 🧚

also, for the record: NetBSD curses since 2.0 (2004) supports keyok. so it's not just an ncurses-exclusive thing, it's been around. vintage. ✨


πŸ‘‘ AUTHORS πŸ‘‘

Thomas Dickey

(thank you king, we appreciate you 🫢)


πŸ’– SEE ALSO πŸ’–

  • curses(3X)
  • define_key(3X)
  • keybound(3X)
  • keyok(3X)
  • key_defined(3X)

go read those next, they're all part of the same friend group iykyk πŸ¦‹


and that's the whole page, bestie!! πŸŽ€ this was ncurses 6.6, dated 2025-10-04, and honestly it ate. now go forth and enable/disable your function keys with intention. mwah πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from