Detect just ctrl key pressed?

I’m putting a game into MAME (the arcade simulator) and it requires the fire key to be the control key. How do I detect just the control key has been pressed. I’m currently using the keyDown method but know I should move to something a bit more modern.

Has anybody else tried putting a java application into MAME? Were there any issues I should be aware of?

Cheers

Mike

Wouldn’t it be KeyEvent.VK_CTRL ?

if (e.isControlDown()) { // Control is down (e is an InputEvent)
    // Do stuff
}

@Zushii
I don’t think he is using Java mouse listeners, but some other library

@Supamagier
What library is this from? Looking at the MAME website, it doesn’t seem like it is Java.

You’re right - I was using the old keyDown method cause that’s what I started using years ago. I looked up the VK_CONTROL and had a play with the new keyPressed listeners and they now work fine. Thanks for the pointers.

Mike

Huh, I never knew there was an InputEvent class.
There is an isControlDown() method in InputEvent, which MouseEvent extends. Looking at the source code of InputEvent, it seems like it is using an int variable called modifiers as a way to flag certain bits. Control is represented as 0x2.
Well anyway, VK_CONTROL is the best method to use here.