You must be logged in to do that.

GetKeyBuffer

GetKeyBuffer
string GetKeyBuffer()

Documentation

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.

Example Usage

// 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!
Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.