This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I found some things when using a KeyListener that seems strange to me.
1. There is a InputEvent.ALT_GRAPH_DOWN_MASK that can be used to check if the Alt Graph is down, however whenever I press the Alt Graph key, the keyPressed method is called twice, first with Ctrl as the modifier and then with Ctrl+Alt as modifiers. Seems to me like it simulates Ctrl+Alt being pressed. Why even have a InputEvent.ALT_GRAPH_DOWN_MASK if it's never used? Or is it meant to be used with somthing else? Or is there something else that is the reason?
2. When presseing the Alt key twice in a row, the second time the keyPressed event is never fired. On the third time the method will be called again.
3. When pressing the Alt key once and then pressing the Ctrl key, then the keyPressed event is never fired no matter how many times you press it, but if you then press ONCE on the Alt key and then press the Ctrl key it will fire.
Key sequence example: Alt, Ctrl, Ctrl, Ctrl, Alt, Ctrl, Ctrl. The key pressed event for presesing the Ctrl will only be fired the two last times Ctrl is pressed. This probablöy have sometinh to do with 2. Seems to be the same if you do it with Shift or Caps lock too.
4. If I press the Alt key once and then press a letter key, then the keyPressed is not fired, however it will be fired if you press the letter once more.
Key sequence example: Alt, B, B, B. The keyPressed event is only fired the last two times when pressing the letter key B. This probably have someting to do with 2.
That was those things that I found, I hope I made any sense. I'd like to know if other peaple are also having the same problem, or is it just someting I have?
Heres is my code that can be run to check these things.