Emulate a key press on the computer

Hello! I am new to arduino.

I want to make the following project: Connect the ADXL335 accelerometer to arduino - and use it like a real balancing board: http://www.make-digital.com/make/vol25?pg=73#pg73

But I don't want to programm the "balancing game" in processing - I want to control my flash game for example - which is waiting for key presses.

So I was wondering if I could produce/simulate a virtual/fake key press - like the letter 'A' oder the right arrow key with processing?

One way to do it is to pull the electronics out of a thrift-store USB keyboard and have the Arduino control switches across the desired keys of the keyboard matrix.

Hm pretty much effort for a simple "button press".

Maybe this could be a solution - arduino "uses" processing -> http://processing.org/discourse/yabb2/YaBB.pl?num=1229624920

This uses this java-"robot"-class: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html

So since I don't own the arduino (wanted to check first if it is possible to make my project) - could someone tell me if this would work with arduino?

final int CAPS_LOCK = 20;
final int NUM_LOCK = 144;
final int SCROLL_LOCK = 145;


Robot r;
void setup()
{
  size(100,100);
  try{
    r = new Robot();
  }catch(AWTException a){}
}

void draw()
{
  int v = (int)random(3);
  switch(v){
    case 0:
    r.keyPress(CAPS_LOCK);
    r.keyRelease(CAPS_LOCK);
    break;
    case 1:
    r.keyPress(NUM_LOCK);
    r.keyRelease(NUM_LOCK);
    break;
    case 2:
    r.keyPress(SCROLL_LOCK);
    r.keyRelease(SCROLL_LOCK);
    break;
  }
}

That looks like processing code, the "only" thing you need to do is build this pipeline

ADXL335 => Arduino => Serial => Processing => keyboard.

Another solution is to let the arduino emulate a ps2 keyboard, you can find code on the playground - http://www.arduino.cc/playground/Main/PS2KeyboardExt2

Another solution is to reprogram the USB port of the UNO to make the UNO behave as a Keyboard - http://hunt.net.nz/users/darran/ You can find him on the forum too.

Succes, Rob