0

I plan on making a chat for a game that uses Canvas, but that isn't the point, this is: http://prntscr.com/3igt4e

As you can see, the user is holding Shift and pressing 1, this would normally produce an exclamation mark, though in this case KeyAdapter outputs a shift.

e.isShiftDown() doesn't really work. I don't really feel I want to use

if(e.isShiftDown() && [SpecificKey])

to check if every specific key is down anyways, so is there a key adapter option that automatically does this for you?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user3625168
  • 85
  • 1
  • 8
  • Why AWT rather than Swing? See my answer on [Swing extras over AWT](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon using AWT components. – Andrew Thompson May 13 '14 at 07:20

1 Answers1

0

You could use multiple cases like:

case KeyEvent.VK_COMMA: return "COMMA";
case KeyEvent.VK_BRACERIGHT: return "BRACERIGHT";

Other options are: VK_EXCLAMATION_MARK, VK_LEFT_PARENTHESIS etc. You could get a list of all such cases in any good IDE or could refer the Documentation.

cprakashagr
  • 751
  • 11
  • 28
  • This wouldn't work as I use int key = e.getKeyCode(); Game.getChat().passText(e.getKeyText(key)); To pass text into my String that is being displayed on the chat box. – user3625168 May 12 '14 at 07:26
  • And if I add if(key == KeyEvent.VK_EXCLAMATION_MARK){ Game.getChat().passText("!"); } To it after, it doesn't do a thing for some strange reason. – user3625168 May 12 '14 at 07:30