Home

onKeyMultiple

onKeyMultiple is a callback method in the Android framework used to handle key events that occur multiple times for a single key press, such as when a key is held down or when a key generates repeated input. It is invoked by a component that receives key events, typically an Activity, and can be overridden to implement custom handling for repeated key input.

The method signature is boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event). It receives the key code

Override this method to provide synthesis for repeated input; return true if the event is handled, otherwise

Example usage:

@Override

public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {

// handle repeated navigation or action

return true;

}

Related callbacks include onKeyDown and onKeyUp, as well as the KeyEvent class. Developers should test across

of
the
key
that
is
repeating,
the
number
of
repeats,
and
the
KeyEvent
object
that
describes
the
event.
The
event’s
action
is
usually
KeyEvent.ACTION_MULTIPLE,
and
the
repeatCount
reflects
how
many
times
the
key
has
repeated
since
the
initial
press.
return
false
to
allow
default
processing.
Note
that
not
all
devices
or
keyboards
generate
onKeyMultiple;
many
apps
rely
on
onKeyDown
with
event.getRepeatCount()
for
repeated
input.
devices
to
ensure
consistent
behavior.