Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Mar 1998 19:12:40 +1000 (EST)
From:      Raymond D Newman <raymond@one.com.au>
To:        undisclosed-recipients:;
Subject:   Key events in JDK port to FreeBSD
Message-ID:  <199803030912.TAA08294@one.one.com.au>

next in thread | raw e-mail | index | archive | help
To:   freebsd-java@FreeBSD.ORG

The following is a problem sun failed to come to grips with - so I'm
not supprised that the FreeBSD port is a little inconsistent.

The java code below is designed to display key event codes.
With the sun JDK 1.1.5 and 1.2beta, the keycodes for the numeric
keypad change depending on the "numlock" status - this is junk
considering "normal" keyboards don't have a numlock key.

With the latest JDK port on FreeBSD 2.2.5 I get some interesting and
confusing results using X with fvwm.

When the keyboard is "standard", the numbers 1 to 9 on the numeric
keypad don't register (ie. no interupt), all other KP keys work
including both the minus and comma (which is different to sun).

When I use xmodmap to tell X to use "Digital" style keys, PF1 -> PF4
and the comma keys stop working and the numbers (1 to 9) now give keycodes.

In both cases the KPEnter and Return keys give the same code (10) and
the Do, Help and some other function keys don't seem to work at all.

Is there some way I can get a unique key code from every key on the
keyboard no matter what X has been told?

Ray Newman

AKey.java
---------
import java.awt.*;
import java.awt.event.*;
public class AKey extends Frame implements KeyListener  //Create our class
{ public AKey()                                         //Constructor
  { Panel centerPanel = new Panel();                    //Use the center
    setLayout(new BorderLayout());                      //standard layout mgr
    addKeyListener(this);                               //Add key listner
  }
  public void keyPressed(KeyEvent e)                    //Catch key presses
  { int keyCode = e.getKeyCode();                       //Get the key pressed
    int modifiers = e.getModifiers();                   //and the modifiers
    System.err.println("Press="+keyCode+" Mod="+modifiers);
  }
  public void keyReleased(KeyEvent e)
  { int keyCode = e.getKeyCode();                        //Get the key
    int modifiers = e.getModifiers();                    //and the modifiers
    System.err.println("Release="+keyCode+" Mod="+modifiers);
  }
  public void keyTyped(KeyEvent e)
  {
  }
  public static void main(String args[])
  { AKey window = new AKey();
    window.pack();
    window.show();
  }
}                                                       //end class AKey

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803030912.TAA08294>