File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Detect AltGr key? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Detect AltGr key?" Watch "Detect AltGr key?" New topic
Author

Detect AltGr key?

David BalaĹžic
Ranch Hand

Joined: May 15, 2008
Posts: 86
Hi!

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 http://java.sun.com/docs/books/tutorialJWS/uiswing/events/ex6/KeyEventDemo.jnlp

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?

Regards,
David
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Detect AltGr key?
 
Similar Threads
Key Event of Special Keys on Keyboard
Key binding problem
Detecting Key Presses in Windows (without focus)
Detecting Key Presses in Windows (without focus)
Who can type with all ten fingers?