Write a program to implement keyboard events / * applet>*/ import java.awt.*; import java.awt.event.*; import java.applet.*; public class keyevent extends Applet implements KeyListener { final Font fnt=new Font("Verdana",Font.PLAIN,15); String msg="KeyEvents ->"; public void init( ) { addKeyListener(this); requestFocus(); } public void paint(Graphics g) { g.setFont(fnt); g.drawString(msg,20 ,30 ); } public void keyPressed(KeyEvent k) { showStatus("KEY PRESSED"); int key=k.getKeyCode(); msg="PRESSED KEY IS: "; switch(key) { case KeyEvent.VK_UP: msg+="MOVE TO UP"; break; case KeyEvent.VK_DOWN: msg+="MOVE TO DOWN"; break; case KeyEvent.VK_LEFT: msg+="MOVE TO LEFT"; break;case KeyEvent.VK_RIGHT: msg+="MOVE TO RIGHT"; break; } repaint(); } public void keyReleased(KeyEvent k) { showStatus("KEY RELEASED"); } public void keyTyped(KeyEvent k) { showStatus("KEY TYPED"); msg="YOU TYPED :"; msg+=k.getKeyChar(); repaint(); } }