@Retention(value=CLASS) @Target(value=METHOD) public @interface KeyDown
This annotation is intended to be used on methods to receive action down
event on a key. This annotation can be used on methods of classes which
implements KeyEvent.Callback.
The annotation value should be one or several of
KeyEvent constant fields which name contains KEYCODE. If
not set, the method name will be used as the KeyEvent
.KEYCODE_* field name.
The method may return a boolean, void, or a
Boolean. If returning void, it will be considered as returning true
(ie: the method has handled the event).
The method MAY have one parameter:
KeyEvent parameter to know which key has been down
Example :
@EActivity
public class MyActivity extends Activity {
@KeyDown
void enter() {
// ...
}
@KeyDown
void onEnter() {
// ...
}
@KeyDown
void onEnterPressed() {
// ...
}
@KeyDown
void enterPressed() {
// ...
}
@KeyDown(KeyEvent.KEYCODE_0)
void keyZeroIsDown(KeyEvent keyEvent) {
// ...
}
@KeyDown({ KeyEvent.KEYCODE_M, KeyEvent.KEYCODE_N })
boolean multipleKeys(KeyEvent keyEvent) {
return false;
}
}
KeyEvent,
KeyEvent.Callback,
KeyEvent.Callback.onKeyDown(int, android.view.KeyEvent)| Modifier and Type | Optional Element and Description |
|---|---|
int[] |
value
The
KeyEvent class constants which name contains
KEYCODE. |
Copyright © 2010–2020 simpligility technologies inc.. All rights reserved.