import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/* <applet code="KeyPress" width="300" height="300">
   </applet>
*/

// Copyright Samar Abbas 2000

public class KeyPress extends Applet implements KeyListener
{

 String msg;
 char k;
 int x = 130;
 int y = 150;

 public void init()
 {
  addKeyListener(this);
 }

 public void keyPressed(KeyEvent ke)
 {
  k = ke.getKeyChar();
  msg = "Key Pressed is " + k;
  repaint();
 }

 public void keyReleased(KeyEvent ke)
 {
  k = ke.getKeyChar();
  msg = "Key Released is "+k;
  repaint();
 }

 public void keyTyped(KeyEvent ke)
 {
  k = ke.getKeyChar();
  msg = "Key Typed is "+k;
  repaint();
 }

 public void paint(Graphics g)
 {
  Font f = new Font( "Times", Font.ITALIC, 24 );
   setFont(f);
   setBackground(Color.black); 
   setForeground(Color.cyan);
  g.drawString(msg,x,y);
 }

}


