KeyboardActionListener.java revision 5a309f57155fb95667c2ccdda730eaf175de8876
1/* 2 * Copyright (C) 2010 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 17package com.android.inputmethod.keyboard; 18 19public interface KeyboardActionListener { 20 21 /** 22 * Called when the user presses a key. This is sent before the 23 * {@link #onKey} is called. For keys that repeat, this is only 24 * called once. 25 * 26 * @param primaryCode 27 * the unicode of the key being pressed. If the touch is 28 * not on a valid key, the value will be zero. 29 */ 30 void onPress(int primaryCode); 31 32 /** 33 * Called when the user releases a key. This is sent after the 34 * {@link #onKey} is called. For keys that repeat, this is only 35 * called once. 36 * 37 * @param primaryCode 38 * the code of the key that was released 39 */ 40 void onRelease(int primaryCode); 41 42 /** 43 * Send a key press to the listener. 44 * 45 * @param primaryCode 46 * this is the key that was pressed 47 * @param keyCodes 48 * the codes for all the possible alternative keys with 49 * the primary code being the first. If the primary key 50 * code is a single character such as an alphabet or 51 * number or symbol, the alternatives will include other 52 * characters that may be on the same key or adjacent 53 * keys. These codes are useful to correct for 54 * accidental presses of a key adjacent to the intended 55 * key. 56 * @param x 57 * x-coordinate pixel of touched event. If onKey is not called by onTouchEvent, 58 * the value should be NOT_A_TOUCH_COORDINATE. 59 * @param y 60 * y-coordinate pixel of touched event. If onKey is not called by onTouchEvent, 61 * the value should be NOT_A_TOUCH_COORDINATE. 62 */ 63 void onKey(int primaryCode, int[] keyCodes, int x, int y); 64 65 /** 66 * Sends a sequence of characters to the listener. 67 * 68 * @param text 69 * the sequence of characters to be displayed. 70 */ 71 void onText(CharSequence text); 72 73 /** 74 * Called when user released a finger outside any key. 75 */ 76 void onCancel(); 77 78 /** 79 * Called when the user quickly moves the finger from right to 80 * left. 81 */ 82 void swipeLeft(); 83 84 /** 85 * Called when the user quickly moves the finger from left to 86 * right. 87 */ 88 void swipeRight(); 89 90 /** 91 * Called when the user quickly moves the finger from up to down. 92 */ 93 void swipeDown(); 94 95 /** 96 * Called when the user quickly moves the finger from down to up. 97 */ 98 void swipeUp(); 99} 100