Name
Input
Synopsis
$cons
->Input
Reads an event from the input buffer. Returns a list of values, determined by the type of event. A keyboard event will contain the following values, in order:
Event type (
1
for keyboard)Key state—true if the key is being pressed, false if the key is being released
Repeat count—the number of times the key is held down
Virtual keycode of the key
Virtual scancode of the key
ASCII code of the character (if the key is a character key,
0
otherwise)State of the control keys (Shifts, Ctrls, Alts, etc.)
A mouse event will return the following values, in order:
Event type (
2
for mouse)X coordinate (column) of the mouse location
Y coordinate (row) of the mouse location
Button state—the mouse button(s) that are pressed
State of the control keys (Shifts, Ctrls, Alts, etc.)
Event flags for the type of the mouse event
This method will return undef
on error.
Note that the events returned depend on the input mode of
the console; for example, mouse events are not intercepted
unless ENABLE_MOUSE_INPUT
is
specified.
Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.