[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

keyname, key_name Subroutine

Purpose

Gets the name of keys.

Library

Curses Library (libcurses.a)

Syntax

#include <curses.h>

char *keyname(int c);

char *key_name(wchar_t c);

Description

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.

Parameter

c

Return Values

Upon successful completion, the keyname subroutine returns a pointer to a string as described above, Otherwise, it returns a null pointer.

Examples

int key;
char *name;
keypad(stdscr, TRUE);
addstr("Hit a key");
key=getch();
name=keyname(key);
Note
If the Page Up key is pressed, keyname will return KEY_PPAGE.

Related Information

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.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]