BlitzKeyboard is live!

After a mammoth coding session tonight I have committed the first version of BlitzKeyboard into the PixelBlitz Engine.

I’m really happy with this work – it’s pretty much everything I’ve ever wanted from an advanced keyboard handler 🙂

So what can it do for you? In short it’s about saving you time. At the core is an extremely fast keyboard event handler, so all you need to do is ask it if a key is pressed or not:

[as]
if (keyboard.isDown(BlitzKeyboard.LEFT))
{
player.x -= playerXSpeed;
}

if (keyboard.isDown(BlitzKeyboard.RIGHT))
{
player.x += playerXSpeed;
}
[/as]

Simple. Fast. Efficient. Of course if that was all it could do it would be nothing special – but it can do so much more …

Multiple Key Support
Accurate detection for one, two or three simultaneous key presses, including Location support. That means you can check for the difference between the left shift key and the right shift key. A full range of constants are built into the class, so rather than remember which keycode relates to which key, you just use our constants list. This list has been extended to support Enhanced keyboards, so you’ve got it detecting the Windows (or Apple Command) keys as well as the Application key.

Set the Key Rate
In an arcade game you need to pick-up the key presses as fast as possible, and BlitzKeyboard does just that. But you can also configure a Key Rate, so if you only want a certain key to fire once every second then that’s no problem.

Bind Events or Functions to Keys
You can set a key (or key combination) to fire an Event or call a Function. You control if the Event should fire when the key/s are pressed down, or fire on the release (when you let them go again). You pass in the Event and then set an event listener to listen out for it, and it handles the rest. It even takes the Key Rate into account, so your Event will only fire at the frequency you set.

Wait Key support
Say you need to wait for the user to press a key before proceeding with your game – then just use the waitKey() function! You pass it an Event and a type, and the next time a key is pressed the Event is dispatched, no matter which key caused it.

Key Hit Counter
Want to know exactly how many times a key has been pressed? Then call keyHit() on it and this method will tell you just that.

I’ll be adding a few final features, and preparing the demos in the coming days. But the core class now exists in Google Code for the curious.

Next up is BlitzMouse which will handle advanced mouse events – things like mouse zones, reporting on how fast the mouse is moving, scroll wheel handling and more.

Posted on September 2nd 2008 at 4:54 am by .
View more posts in PixelBlitz. Follow responses via the RSS 2.0 feed.


3 Responses

Leave a comment

Make yourself heard