Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2007

Tip: Looking for answers? Try searching our database.

keypressed of up arrow not received when Ctrl is also pressed

Thread view: 
Jack - 18 Dec 2007 17:21 GMT
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"...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.