1

Is there any event for pressing ?, such as keyPress(KeyEvent.VK_?) in Java?

RAS
  • 8,100
  • 16
  • 64
  • 86
Marco
  • 985
  • 7
  • 22
  • 50
  • 1
    You've asked [two questions in a row](http://stackoverflow.com/questions/8384996/what-is-the-java-keyevent-field-for-dot) about KeyEvent fields. Please (a) read the [KeyEvent documentation](http://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html) and (b) put some effort into your questions. It would not be difficult to write a program which printed out the keys which were pressed, and then you could type a dot or a question mark and see for yourself what comes out. – Michael Myers Dec 05 '11 at 15:57
  • ehhh ... "too localized" - to which narrow area, time, community is a question mark's importance limited? Fully agreed that the qustion is lacking, but such is the reason for closing ... – kleopatra Dec 07 '11 at 18:56

1 Answers1

5

From http://docs.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html:

Not all characters have a keycode associated with them. For example, there is no keycode for the question mark because there is no keyboard for which it appears on the primary layer.

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
  • There is indeed no keycode associated with "?" but a way to check if "?" is pressed (SHIFT + "/" for my keyboard) is to call `getKeyChar()` on a `KeyEvent` and check if that matches `'?'`. – Rob van der Leek Aug 05 '20 at 20:48