Home

keyReleased

KeyReleased is a type of keyboard event in graphical user interfaces and games that signals when a key on the keyboard has been released after being pressed. It is part of the standard event model used by many frameworks to handle keyboard input.

In Java's AWT and Swing, keyReleased is one of the methods of the KeyListener interface, alongside keyPressed

KeyReleased is commonly used to update internal state after a key is released, to trigger actions on

Relationship to other events: keyPressed fires when the key goes down, keyReleased when it goes up, and

Example (Java):

class MyListener implements java.awt.event.KeyListener {

@Override public void keyPressed(KeyEvent e) { }

@Override public void keyReleased(KeyEvent e) {

if (e.getKeyCode() == KeyEvent.VK_ENTER) {

// handle enter release

}

}

@Override public void keyTyped(KeyEvent e) { }

}

See also: keyPressed, keyTyped.

and
keyTyped.
A
class
implementing
KeyListener
receives
a
KeyEvent
when
the
user
lifts
a
key.
The
event
object
provides
details
such
as
the
key
code
(for
example,
VK_A),
the
key
character,
and
modifier
flags
like
Shift
or
Ctrl.
release,
or
to
implement
keyboard
shortcuts
that
depend
on
the
release
timing.
It
is
also
used
in
games
to
detect
when
a
movement
key
stops
being
pressed,
allowing
smooth
transitions
between
states.
keyTyped
is
for
keys
that
produce
character
input.
Some
keys
may
not
generate
keyTyped,
and
delivery
can
be
affected
by
focus,
input
methods,
or
platform-specific
behavior.