Hi,
i have a Swing problem, i don't receive the "keypressed event" for "up arrow" when the Ctrl key is pressed. I have one
computer for which i receive the keyPressed, but another computer the java program doesn't work.
I keep "Ctrl" key pressed, and i type the up arrow key.
On the "working" computer:
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_UP, modifiers = Ctrl
On the "not working" computer:
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
keyPressed keyCode = VK_CONTROL, modifiers = Ctrl
The "up" key is not seen. Do i misuse the Java API, or do you know any bug wich could be the cause of that behavior?
The source code:
======================================
package lc;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
public class ListeClavier {
public static void main(String[] args) {
System.out.println("java.version : " + System.getProperty("java.version"));
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DefaultListModel model = new DefaultListModel();
model.addElement("a");
model.addElement("b");
model.addElement("c");
JList list = new JList(model);
list.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
String key;
switch (e.getKeyCode()) {
case KeyEvent.VK_UP: key = "VK_UP"; break;
case KeyEvent.VK_DOWN: key = "VK_DOWN"; break;
case KeyEvent.VK_CONTROL: key = "VK_CONTROL"; break;
default: key = "" + e.getKeyCode();
}
System.out.println("keyPressed keyCode = " + key + ", modifiers = " + KeyEvent.getKeyModifiersText(e.getModifiers()));
}
});
JScrollPane scrollPane = new JScrollPane(list);
frame.setContentPane(scrollPane);
frame.setVisible(true);
}
}
=====================================
Thnaks for any help
KaL - 18 Dec 2007 19:08 GMT
Il Tue, 18 Dec 2007 18:21:53 +0100, Jack ha scritto:
> Hi,
>
[quoted text clipped - 26 lines]
>
> The source code:
> [...omitted code...]
> Thnaks for any help
Maybe this combination is already bound by another process...
I'm just guessing,
K'
Jack - 19 Dec 2007 08:49 GMT
> Maybe this combination is already bound by another process...
> I'm just guessing,
Thanks, it was Winamp :p
Roedy Green - 19 Dec 2007 07:14 GMT
>The "up" key is not seen. Do i misuse the Java API, or do you know any bug wich could be the cause of that behavior?
Using Keyplayer I see Ctrl-Up Arrow see
http://mindprod.com/products.html#KEYPLAYER
[E:\sys]keyplayer
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="&" 38 cooked KeyChar="."
65535
At keyReleased
ID=402 KeyEvent.KEY_RELEASED raw KeyCode="&" 38 cooked KeyChar="."
65535
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="." 17 cooked KeyChar="."
65535 CTRL
_MASK
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="&" 38 cooked KeyChar="."
65535 CTRL
_MASK
At keyReleased
ID=402 KeyEvent.KEY_RELEASED raw KeyCode="&" 38 cooked KeyChar="."
65535 CTRL
_MASK
At keyReleased
ID=402 KeyEvent.KEY_RELEASED raw KeyCode="." 17 cooked KeyChar="."
65535

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Jack - 19 Dec 2007 08:24 GMT
Roedy Green a écrit :
>> The "up" key is not seen. Do i misuse the Java API, or do you know any bug wich could be the cause of that behavior?
>
[quoted text clipped - 23 lines]
> ID=402 KeyEvent.KEY_RELEASED raw KeyCode="." 17 cooked KeyChar="."
> 65535
On the "not working" computer, i have this:
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="." 17 cooked KeyChar="." 65535 CTRL_MASK
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="." 17 cooked KeyChar="." 65535 CTRL_MASK
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="." 17 cooked KeyChar="." 65535 CTRL_MASK
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="." 17 cooked KeyChar="." 65535 CTRL_MASK
At keyPressed
ID=401 KeyEvent.KEY_PRESSED raw KeyCode="." 17 cooked KeyChar="." 65535 CTRL_MASK
At keyReleased
ID=402 KeyEvent.KEY_RELEASED raw KeyCode="&" 38 cooked KeyChar="." 65535 CTRL_MASK
At keyReleased
ID=402 KeyEvent.KEY_RELEASED raw KeyCode="." 17 cooked KeyChar="." 65535
So the VK_UP (38) keyReleased is received, but not the keyPressed
Roedy Green - 19 Dec 2007 22:55 GMT
>So the VK_UP (38) keyReleased is received, but not the keyPressed
I suspect your OS is not passing the proper keystrokes on. You might
try updating, reinstalling, or changing your keyboard driver.
This a longshot, but try a different keyboard.
You might also look for some non-Java tools to track keystrokes.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Roedy Green - 19 Dec 2007 23:25 GMT
>> http://mindprod.com/products.html#KEYPLAYER
I just posted a new version at
http://mindprod.com/products2.html#KEYPLAYER
It display hex as well.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Jack - 20 Dec 2007 09:30 GMT
Roedy Green a écrit :
>>> http://mindprod.com/products.html#KEYPLAYER
>
> I just posted a new version at
> http://mindprod.com/products2.html#KEYPLAYER
>
> It display hex as well.
Thanks, but it was Winamp.
Lew - 20 Dec 2007 13:31 GMT
> Roedy Green a écrit :
>>
[quoted text clipped - 6 lines]
>
> Thanks, but it was Winamp.
What do you mean, exactly?

Signature
Lew
Jack - 20 Dec 2007 14:00 GMT
Lew a écrit :
>> Roedy Green a écrit :
>>>
[quoted text clipped - 8 lines]
>
> What do you mean, exactly?
Winamp was intercepting Ctrl+Up. I guess is must be "next song"...