Gets the name of keys.
Curses Library (libcurses.a)
#include <curses.h> char *keyname(int c); char *key_name(wchar_t c);
The keyname and key_name subroutines generate a character string whose value describes the key c. The c argument of keyname can be an 8-bit character or a key code. The c argument of key_name must be a wide character.
The string has a format according to the first applicable row in the following table:
Input | Format of Returned String |
Visible character | The same character |
Control character | ^X |
Meta-character (keyname only) | M-X |
Key value defined in <curses.h> (keyname only) | KEY_name |
None of the above | UNKNOWN KEY |
The meta-character notation shown above is used only, if meta-characters are enabled.
c
Upon successful completion, the keyname subroutine returns a pointer to a string as described above, Otherwise, it returns a null pointer.
int key; char *name; keypad(stdscr, TRUE); addstr("Hit a key"); key=getch(); name=keyname(key);
The meta (meta Subroutine) and wgetch (getch, mvgetch, mvwgetch, or wgetch Subroutine) subroutines.
List of Curses Subroutines in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.