KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > ui > KeyboardListener


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.user.client.ui;
17
18 import java.util.EventListener JavaDoc;
19
20 /**
21  * Event listener interface for keyboard events.
22  */

23 public interface KeyboardListener extends EventListener JavaDoc {
24
25   public static final int KEY_ALT = 18;
26   public static final int KEY_BACKSPACE = 8;
27   public static final int KEY_CTRL = 17;
28   public static final int KEY_DELETE = 46;
29   public static final int KEY_DOWN = 40;
30   public static final int KEY_END = 35;
31   public static final int KEY_ENTER = 13;
32   public static final int KEY_ESCAPE = 27;
33   public static final int KEY_HOME = 36;
34   public static final int KEY_LEFT = 37;
35   public static final int KEY_PAGEDOWN = 34;
36   public static final int KEY_PAGEUP = 33;
37   public static final int KEY_RIGHT = 39;
38   public static final int KEY_SHIFT = 16;
39   public static final int KEY_TAB = 9;
40   public static final int KEY_UP = 38;
41
42   public static final int MODIFIER_ALT = 4;
43   public static final int MODIFIER_CTRL = 2;
44   public static final int MODIFIER_META = 8;
45   public static final int MODIFIER_SHIFT = 1;
46
47   /**
48    * Fired when the user depresses a physical key.
49    *
50    * @param sender the widget that was focused when the event occurred.
51    * @param keyCode the physical key that was depressed. Constants for this
52    * value are defined in this interface with the KEY prefix.
53    * @param modifiers the modifier keys pressed at when the event occurred. This
54    * value is a combination of the bits defined by
55    * {@link KeyboardListener#MODIFIER_SHIFT},
56    * {@link KeyboardListener#MODIFIER_CTRL}, and
57    * {@link KeyboardListener#MODIFIER_ALT}.
58    */

59   void onKeyDown(Widget sender, char keyCode, int modifiers);
60
61   /**
62    * Fired when a keyboard action generates a character. This occurs after
63    * onKeyDown and onKeyUp are fired for the physical key that was pressed.
64    *
65    * <p>
66    * It should be noted that many browsers do not generate keypress events
67    * for non-printing keyCode values, such as {@link KeyboardListener#KEY_ENTER}
68    * or arrow keys. These keyCodes can be reliably captured either with
69    * {@link KeyboardListener#onKeyDown(Widget, char, int)} or
70    * {@link KeyboardListener#onKeyUp(Widget, char, int)}.
71    * </p>
72    *
73    * @param sender the widget that was focused when the event occurred.
74    * @param keyCode the Unicode character that was generated by the keyboard
75    * action.
76    * @param modifiers the modifier keys pressed at when the event occurred. This
77    * value is a combination of the bits defined by
78    * {@link KeyboardListener#MODIFIER_SHIFT},
79    * {@link KeyboardListener#MODIFIER_CTRL}, and
80    * {@link KeyboardListener#MODIFIER_ALT}.
81    */

82   void onKeyPress(Widget sender, char keyCode, int modifiers);
83
84   /**
85    * Fired when the user releases a physical key.
86    *
87    * @param sender the widget that was focused when the event occurred.
88    * @param keyCode the physical key that was released. Constants for this value
89    * are defined in this interface with the KEY prefix.
90    * @param modifiers the modifier keys pressed at when the event occurred. This
91    * value is a combination of the bits defined by
92    * {@link KeyboardListener#MODIFIER_SHIFT},
93    * {@link KeyboardListener#MODIFIER_CTRL}, and
94    * {@link KeyboardListener#MODIFIER_ALT}.
95    */

96   void onKeyUp(Widget sender, char keyCode, int modifiers);
97 }
98
Popular Tags