define_key(3ncurses)

define_key3ncurses

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(3NCURSES) (wide-character API users: wget_wch(3NCURSES)) when keypad(3NCURSES) 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

14 releases since Debian 2.1 (Slink); the text changed 10 times.

  1. 2.1
  2. 2.2
  3. 3.0
  4. 3.1
  5. 4.0–5.0
  6. 6.0
  7. 7–9
  8. 10
  9. 11
  10. 12
  11. 13

Authors

Thomas Dickey

From ncurses-doc 6.5+20250216-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.