Most visited

Recently visited

Added in API level 1

KeyEvent.Callback

public static interface KeyEvent.Callback

android.view.KeyEvent.Callback
Known Indirect Subclasses


Summary

Public methods

abstract boolean onKeyDown(int keyCode, KeyEvent event)

当关键事件发生时调用。

abstract boolean onKeyLongPress(int keyCode, KeyEvent event)

长时间按下时发生。

abstract boolean onKeyMultiple(int keyCode, int count, KeyEvent event)

当连续发生同一个键的多个向下/向上对时调用。

abstract boolean onKeyUp(int keyCode, KeyEvent event)

发生关键事件时调用。

Public methods

onKeyDown

Added in API level 1
boolean onKeyDown (int keyCode, 
                KeyEvent event)

当关键事件发生时调用。 如果您返回true,则可以先致电KeyEvent.startTracking()让框架通过其onKeyUp(int, KeyEvent)跟踪事件,并在发生时调用onKeyLongPress(int, KeyEvent)

Parameters
keyCode int: The value in event.getKeyCode().
event KeyEvent: Description of the key event.
Returns
boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyLongPress

Added in API level 5
boolean onKeyLongPress (int keyCode, 
                KeyEvent event)

长时间按下时发生。 如果您返回true,则最终密钥将会设置为FLAG_CANCELEDFLAG_CANCELED_LONG_PRESS 请注意,为了接收此回调,事件更改中的某人必须onKeyDown(int, KeyEvent)返回true 在事件中调用startTracking()

Parameters
keyCode int: The value in event.getKeyCode().
event KeyEvent: Description of the key event.
Returns
boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyMultiple

Added in API level 1
boolean onKeyMultiple (int keyCode, 
                int count, 
                KeyEvent event)

当连续发生同一个键的多个向下/向上对时调用。

Parameters
keyCode int: The value in event.getKeyCode().
count int: Number of pairs as returned by event.getRepeatCount().
event KeyEvent: Description of the key event.
Returns
boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyUp

Added in API level 1
boolean onKeyUp (int keyCode, 
                KeyEvent event)

发生关键事件时调用。

Parameters
keyCode int: The value in event.getKeyCode().
event KeyEvent: Description of the key event.
Returns
boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

Hooray!