define_key(3)

define_key3

Define a curses function key code

Usage

#include <curses.h>

int define_key(const char * definition, int key-code);

Overview

The define_key ncurses extension permits a curses application to bind a string definition to the function key key-code returned by wgetch(3X) (wide-character API users: wget_wch(3X)) when keypad(3X) is enabled in a window and a function key is pressed. ncurses interprets such a binding as it does those in the terminfo database entry for the terminal type.

A definition of NULL removes any existing binding from key-code. Similarly, a non-positive key-code removes an existing binding for definition, if any.

Return value

define_key returns ERR if

•

definition is NULL and key-code is nonpositive, or

•

insufficient memory is available to bind definition to key-code.

Otherwise, define_key returns OK.

Extensions

define_key is an ncurses extension.

Portability

Applications employing ncurses extensions should condition their use on the visibility of the NCURSES_VERSION preprocessor macro.

NetBSD curses since 2.0 (2004) supports define_key.

Releases

70 releases since FreeBSD 4.0-RELEASE; the text changed 9 times.

  1. 4.0–4.11
  2. 5.0–6.2
  3. 6.3–10.4
  4. 11.0–12.4
  5. 13.0–13.5
  6. 14.0–14.1
  7. 14.2–14.4
  8. 14.5
  9. 15.0
  10. 15.1–16.0

Authors

Thomas Dickey

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's man source.