// Demonstrate a keyboard event handler. import java.awt.*; import java.applet.*; public class Klahvistik extends Applet{ String msg = ""; // Handle key press events. public boolean keyDown(Event evtObj, int key) { int k; if (key!=10) msg += (char)key; else try{k=Integer.parseInt(msg) ; msg="OK"+(k+1);} catch (NumberFormatException e){msg="vale formaat";} repaint(); showStatus("Key Down"); return true; } // Handle key release events. public boolean keyUp(Event evtObj, int key) { showStatus("Key Up"); return true; } // Display keystrokes. public void paint(Graphics g) { g.drawString(msg, 10, 20); } }