Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detect AltGr key?

David BalaĹžic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is it possible to detect the AltGr (right alt) key from Java?

Running this program with JRE 1.6.0_15 on Windows XP gives two codes when AltGr is pressed: CTRL and ALT
KeyEvent.isAltGraphDown() always returns false.

The program is

Note: US keyboard layout generates ALT code when the right alt is pressed. Switch the OS keyboard layout setting to German or Slovenian.

I wonder, as currently AltGr appears to be detected as ctrl+alt. That gives problems in Eclipse, because this happens:
(keyboard layout is set to "Slovenian")
- user presses AltGr+W in editor to get the pipe "|" character (this normally works in other non-java programs)
- Eclipse/Java sees ctrl-alt-W
- Eclipse uses the shortcut defined for ctrl-alt-W (mapped to show SVN properties view)
- "|" does not appears in editor

Ideally the ctrl,alt and W keys would trigger that SVN property, while AltGr,W would type |.

Using that test program above gives the impression the Java programs can not detect in the ctrl+alt code comes from those both keys or from the AltGr key.
Or is there a way?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic