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
  • September 2nd 2008 at 1:20 pm

    This sounds like a really cool project. I am looking forward to seeing where this will go and am following closely.

    Could I suggest you add a link to the googlecode page on every post about it so that I don’t have to remember the url :)

  • September 2nd 2008 at 1:41 pm

    Looking forward to see this engine growing! Are you planning to add any tile-based features?

  • September 2nd 2008 at 1:59 pm

    Hi Ben – Glad to see you here! Strangely enough I was on your site just yesterday grabbing Exgen to see if it’d fit into PixelBlitz :) I’m going to add a PixelBlitz page to my blog, which will contain download details and related blog post summaries, then I’ll make the logo link to it. I usually add the link, but it was nearly 5am when I wrote that post!

    sascha – yes, absolutely 100% we will! Norm already has a tile engine in the works (he’s even been building a Flex based tile map editor for it). I want to support more common formats like Tile Studio as well. We need to work on optimising the 2DRenderer though, because at the moment it is copying large amounts of data around even if that data is then totally obscured by a layer above it, which is inefficient.

Make yourself heard