In previous blog, we have talk about the Touch events, also we give some example about how to trigger KeyCode event.
In this chapter, we will talk about the characteristics of KeyCode,
and will also introduce how to use the Input function to input the text content.

Functions

Function Description
keycode(value) Trigger an Android KeyEvent
input(string) Send string into device

keycode(value)

The keycode funtion is using to send Android KeyEvent into your device.
Similar with the Touch event, the Key event is composed with one or more than one ACTION_DOWN events and one ACTION_UP event.

In current version of Blackey Script, we have simplified the Key event behavior,
when the script execute keycode(value), it will send ACTION_DOWN and ACTION_UP event automatically,
but this also means we don’t support long-press key event in current Blackey Script. (•ㅂ•)/

The way to use keycode is just as the example we shows in previous chapter,
just calling the keycode function with certain key value.

// Trigger Power Key
keycode(26);

The KeyCode value we use in Blackey Script is directly mapping to Android KeyEvent,
we list all supported events in this KeyCode table:

KEYCODE ACTION
3 HOME
4 BACK
24 VOLUME UP
25 VOLUME DOWN
26 POWER
66 ENTER
67 BACKSPACE
187 APP SWITCH

input(string)

The input function is using to send text content from PC to device.
You need to click a editable area on the device to launch Input Method, then the input function can start to work.
The way to use input function is also very simple, just input the text directly:

input(“Hello World!”);

Or you can also pass the string by a given variable:

myString = “Hello Blackey”;
input(myString);

With input function, you can filling such as the web address or email address in a short time,
just calling input to type anything you want!