About Buy News Guide Ideas
Get a phatIO device here!

Back to Table of Contents

(keyboard <arg1> <arg2> ... )

Keyboard evaluates each argument as a string and sends to the host computer as keyboard entries.

For example: (keyboard “hello ” (+ 32 11) “\t\n”)

Modifier keys (shift, control, alt, etc.) are typed by surrounding with “%{}”, for example the following would type “s” with the left shift key pressed - “S” - the same as (keyboard "S")

(keyboard "%{LeftShift+s}")

Multiple (upto 6) Modifier Keys can be sent:

(keyboard "%{LeftShift+LeftControl+w}")

Available attributes to %{} are shown below:

keyboard modifiers entered in %{}
Modifier Description
LeftShift left shift key
RightShift right shift key
LeftControl left control key
RightControl right control key
LeftAlt left alt key
RightAlt right alt key
LeftGUI left GUI key
RightGUI right GUI key
0xXX Sends the raw hex USB code XX

See of Appendix C, page 30 of the Keyboard Scan Code Specification for list of the raw hex codes to use with 0xXX.

Note that although the maximum USB keyboard rate is 500 characters per second, few Operating Systems can cope with this rate. Currently phatIO will wait 20ms between sending characters - 50 characters per second. A future version of phatIO will allow customization of this rate.

For example, the following would quit the current program when the relevant pin goes low on windows and OS X respectively:

(pinmode 0 HIGH)
(pin_goes_low 0 (keyboard "%{LeftGUI+q}"))
(pinmode 1 HIGH)
(pin_goes_low 1 (keyboard "%{LeftAlt+0x3D}")); Alt F4

(fmt <format> arg)

Evaluates arg as a number and then returns a formatted string. Format is the same as stdlib printf format.

@Contact  |   Legal & Privacy  |    RSS  |   Development Twitter  |   Official Twitter
© phatIO 2012, All Rights Reserved.