1. /*
  2. * @(#)KeyListener.java 1.11 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.event;
  8. import java.util.EventListener;
  9. /**
  10. * The listener interface for receiving keyboard events (keystrokes).
  11. * The class that is interested in processing a keyboard event
  12. * either implements this interface (and all the methods it
  13. * contains) or extends the abstract <code>KeyAdapter</code> class
  14. * (overriding only the methods of interest).
  15. * <P>
  16. * The listener object created from that class is then registered with a
  17. * component using the component's <code>addKeyListener</code>
  18. * method. A keyboard event is generated when a key is pressed, released,
  19. * or typed (pressedn and released). The relevant method in the listener
  20. * object is then invoked, and the <code>KeyEvent</code> is passed to it.
  21. *
  22. * @see KeyAdapter
  23. * @see KeyEvent
  24. * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
  25. * @see <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
  26. *
  27. * @version 1.11 11/29/01
  28. * @author Carl Quinn
  29. */
  30. public interface KeyListener extends EventListener {
  31. /**
  32. * Invoked when a key has been typed.
  33. * This event occurs when a key press is followed by a key release.
  34. */
  35. public void keyTyped(KeyEvent e);
  36. /**
  37. * Invoked when a key has been pressed.
  38. */
  39. public void keyPressed(KeyEvent e);
  40. /**
  41. * Invoked when a key has been released.
  42. */
  43. public void keyReleased(KeyEvent e);
  44. }