KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > event > KeyListener


1 /*
2  * @(#)KeyListener.java 1.18 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt.event;
9
10 import java.util.EventListener JavaDoc;
11
12 /**
13  * The listener interface for receiving keyboard events (keystrokes).
14  * The class that is interested in processing a keyboard event
15  * either implements this interface (and all the methods it
16  * contains) or extends the abstract <code>KeyAdapter</code> class
17  * (overriding only the methods of interest).
18  * <P>
19  * The listener object created from that class is then registered with a
20  * component using the component's <code>addKeyListener</code>
21  * method. A keyboard event is generated when a key is pressed, released,
22  * or typed. The relevant method in the listener
23  * object is then invoked, and the <code>KeyEvent</code> is passed to it.
24  *
25  * @author Carl Quinn
26  * @version 1.18 12/19/03
27  *
28  * @see KeyAdapter
29  * @see KeyEvent
30  * @see <a HREF="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
31  * @see <a HREF="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
32  *
33  * @since 1.1
34  */

35 public interface KeyListener extends EventListener JavaDoc {
36
37     /**
38      * Invoked when a key has been typed.
39      * See the class description for {@link KeyEvent} for a definition of
40      * a key typed event.
41      */

42     public void keyTyped(KeyEvent JavaDoc e);
43
44     /**
45      * Invoked when a key has been pressed.
46      * See the class description for {@link KeyEvent} for a definition of
47      * a key pressed event.
48      */

49     public void keyPressed(KeyEvent JavaDoc e);
50
51     /**
52      * Invoked when a key has been released.
53      * See the class description for {@link KeyEvent} for a definition of
54      * a key released event.
55      */

56     public void keyReleased(KeyEvent JavaDoc e);
57 }
58
Popular Tags