string GetKeyBuffer()
Returns a buffer of recent keys pressed in string form. This function is useful for capturing text input from the keyboard. You should use FlushKeyBuffer(); after the key buffer is retrieved, so that future calls return only new characters.
It allows typing of the standard characters and their upper cases, as well as buffering of enter, tab, and backspace. Backspaces should be iterated through via a VergeC-side loop in order to work, like the example shows.
// Assumes you've declared the following. // int i; for iteration // int ch; to store current character being checked. // string buf; to store all the character retreived from the key buffer. // string s; for the string to store the all the typing after it's been handled. buf = GetKeyBuffer(); for (i = 0; i < len(buf); i++) { ch = asc(mid(buf, i, 1)); if (ch == 8) { if (len(s)) { s = left(s, len(s) - 1); } } if (ch == '\n') { // SUBMIT TEXT. // If this newline check is ignored, it'll be printed in the text. } else if (ch == '\t') { s += " "; } else { s += chr(ch); } } FlushKeyBuffer(); // Remember to do this after you've checked all the input!
There are no talkbacks on this documentation page yet. Post the first?
Doc Nav |
Your docs |