One key, two actions

Hi, I have a question:
Can one key operate two actions? Like if you press Q key it do what you have wrote,
but when you press Q key again it do the other action.
I want to use this for my Parking Brake on my vehicle. I have tried some options but is dont work.
Thanks.

Hi friend
As one way you can create a Boolean like MyBoll . and in your action listener do :

 private ActionListener actionListener = new ActionListener() {
    public void onAction(String name, boolean keyPressed, float tpf) {
      if (MyBoll) {
        //do something
        MyBoll=false;
      }
     else{
         // do other thing
         MyBoll=true;
     }
    }
  };

Yes its good, but I want that action will be forever, like when the key is not pressed.

I just fix it now :smile: I add && !value to condition line:

private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
  if (player.equals("action")&& !value)) {
  if (MyBoll) {
    //do something
    MyBoll=false;
  }
 else{
     // do other thing
     MyBoll=true;
  }
 }
}

Thanks you som much :smiley: