this applet is to demonstrate the low level keyboard event handling in java. It offers the minimum needs for a JMB porting.
Regards
import java.applet.Applet;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/*
* Created on Sep 13, 2005
*/
/**
* @author ldomen
*/
public class Jmb extends Applet implements KeyListener
{
private static long startTime = -1;
private static long endTime =-1;
private static int lastKeyCode =-1;
public void init()
{
setSize(400, 400);
setVisible(true);
this.addKeyListener(this);
}
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
int lkc = e.getKeyCode();
if (lkc == lastKeyCode )
{
// do nothing ... Ignore autorepeat ...
}
else
{
startTime = e.getWhen();
lastKeyCode = lkc;
write("PRESSED event :" + e.getKeyChar() + " in "+startTime);
}
}
public void keyReleased(KeyEvent e)
{
endTime = e.getWhen();
lastKeyCode = -1;
write("RELEASED event :" + e.getKeyChar() + " DELAY=" + (endTime - startTime));
}
private void write(String s)
{
System.out.println(s);
}
}
--
Luciano Domenico Giordana
Software Engineer / Java/C++ Senior Developer
IBM Brasil - Hortolândia - SP - +55 19 21327000 - R 5100
Project Protux : http://www.nongnu.org/protux
_______________________________________________ Protux-devel mailing list Protux-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/protux-devel