define_key(3x) — Linux manual page

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | EXTENSIONS | PORTABILITY | AUTHORS | SEE ALSO | COLOPHON

define_key(3X)                Library calls                define_key(3X)

NAME         top

       define_key - define a curses function key code

SYNOPSIS         top

       #include <curses.h>

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

DESCRIPTION         top

       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         top

       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         top

       define_key is an ncurses extension.

PORTABILITY         top

       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.

AUTHORS         top

       Thomas Dickey

SEE ALSO         top

       curses(3X), keybound(3X), keyok(3X), key_defined(3X), terminfo(5)

COLOPHON         top

       This page is part of the ncurses (new curses) project.
       Information about the project can be found at 
       ⟨https://invisible-island.net/ncurses/ncurses.html⟩.  If you have a
       bug report for this manual page, send it to bug-ncurses@gnu.org.
       This page was obtained from the tarball ncurses-6.6.tar.gz fetched
       from ⟨https://ftp.gnu.org/gnu/ncurses/⟩ on 2026-01-16.  If you
       discover any rendering problems in this HTML version of the page,
       or you believe there is a better or more up-to-date source for the
       page, or you have corrections or improvements to the information
       in this COLOPHON (which is not part of the original manual page),
       send a mail to man-pages@man7.org

ncurses @NCURSES_MAJOR@.@NCU... 2024-12-28                 define_key(3X)