inchar (STRING*)
inkey (STRING*)
Enters keyboard input into the given string. The local
keyboard layout is activated.
inchar() waits until a key is pressed, reads it into the string, and returns its ASCII value; inkey() reads characters into the string until the input is terminated with [Enter] or [Tab].
Parameters:
STRING* - String pointer to receive keyboard
entry, or NULL for just returning the key value.
Returns:
1 |
Input terminated prematurely because inkey_active was set to 0 or
another keyboard entry was active at the same time. |
9 |
Input terminated by [Tab] |
13 |
Input terminated by [Enter] |
27 |
Input aborted by [Esc] |
72 |
Input aborted by [Up] |
73 |
Input aborted by [PgUp] |
80 |
Input aborted by [Down] |
81 |
Input aborted by [PgDn] |
other |
ASCII value of the pressed key. |
Modifies:
STRING |
String receives keyboard entry. |
inkey_active |
Set to 1 (inkey) or 2 (inchar) during entry. |
Remarks:.
-
The
text
of the inkey() input can be edited during entry using the [BackSpace], [Del], [Right], [Left], [Home] and [End] keys. The original length of the string is not exceeded. Pressing [Esc], [Up], [Down], [PgUp], [PgDn] or [F1]..[F11] aborts inkey(); the previous content of the string is then restored, and the scan code of the key is returned.
- If the string appears in a TEXT object displayed on screen, the input as well as a cursor are visible. The cursor is the character 127 from a bitmap font, or the character 59 (underscore '_') from a TrueType font. The str_cursor function can be used to get the current cursor position while the string is edited.
- Keyboard entry can be aborted externally by setting the inkey_active variable
to 0.
-
Key events (on_a etc.) are inactive during keyboard
entry, and game_save/game_load functions are not executed.
-
The functions perform internal wait() calls and thus can not be used by external languages. They are not exported in acknex.dll.
Examples (lite-C):
STRING* entry_str = " "; // long empty string
...
var key = inkey(entry_str); // wait until [enter] pressed
if (key == 13)
process_entry(entry_str);
...
STRING* string1 = "";
STRING* string2 = "";
...
while(1) {
if (inchar(string1) == 13) break;
str_cat(string2,string1);
}
See also:
inkey_active, str_cursor, key_a,...,key_z,
on_, key_for_string,
str_for_key, key_set
► latest
version online