HookKey

HookKey
void HookKey(int key, string function)

Documentation

Each time the key, set by a scan code is pressed the function is called. Note this is once and only per key press, it is not called repeatedly if the key is held. It needs to be released then pressed again to trigger another function call. As with all hook functions, it requires the string of a function name that requires no passed values, and any return value is ignored. To remove the hook, call pass "" as the function name. Where you can, use HookButton() instead, as this also supports gamepad input.

Example Usage

// Put this in system.vc and it will actually compile and run...
void AutoExec()
{
	// Hooks the up key to the function
	HookKey(SCAN_UP, "UpKeyHook");
	// Stay in the program loop until escape is pressed
	while (!b3)
	{
		UpdateControls();
	}
	Exit("Well, if you will take another lover...");
}

// If up arrow is pressed
void UpKeyHook()
{
	// Display a little message box
	MessageBox("One up key has been pressed.");
}
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.