key events & capturing special keys

To make my new game fully compatible with MAME (an arcade emulator) I need to support the user pressing ALT as the secondary fire button (CTRL and space are the other fire buttons). My code captures the key press using KeyEvent and fires the right weapon but it then sits around waiting for another key to be pressed because the ALT key was pressed. How do I make it treat the ALT key just like any other key press?

Many thanks

Mike

PS do you think a player can cope with having 3 different weapons? is it too many or is it more the better?

VK_ALT should work just fine.

A code fragment (and the OS you’re using) might help identify the problem.

Thanks for replying so soon. I am using VK_ALT but when I press that during a game, the game will wait until I press something else before accepting more input - not just firing input but movement etc. Actually it seems to wait for me to press the ALT key again before resuming play. The game doesn’t freeze but it just doesn’t accept any key presses until I press ALT again. Weirdly pressing escape will also bring it out of ALT mode. This seems to tie in with the ALT key expecting another key. I usually avoid code samples because others are a bit more picky about coding standards :wink:

I don’t usually use the ALT key on my keyboard so I have no idea what it’s proper behaviour should be.

	private boolean isFireButton( int key ) {
		if ( MameMode == 0 ) {
			// normal PC controls
			// weapons are switched using up/down keys
			return key == KeyEvent.VK_CONTROL || key == KeyEvent.VK_SPACE;
		} else {
			// arcade cabinet controls where CTRL, ALT and space are all separate weapon fire buttons
			if ( key == KeyEvent.VK_CONTROL ) {
				WeaponMode = 0;
				return true;
			} else if ( key == KeyEvent.VK_ALT && MaxWeaponMode > 1 ) {
				WeaponMode = 1;
				return true;
			} else if ( key == KeyEvent.VK_SPACE && MaxWeaponMode > 2 ) {
				WeaponMode = 2;
				return true;
			}
		}

		return false;
	}