ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. injectBrowserKey

Function

injectBrowserKey

ClientBrowserTrilogy Hub only

Sends a key press or release to the page (e.g. Enter, Backspace, arrows), as if the player pressed it on the keyboard. The page gets normal keydown / keyup events. Use injectBrowserCharacter to type text.

Syntax

bool injectBrowserKey(browser webBrowser, string/int key [, bool down = true, table modifiers = {}])

Arguments

webBrowserbrowser
The browser.
keystring/int
Key name as in bindKey ("enter", "backspace", "tab", "arrow_l", "a", "f5", "num_3"…) or a Windows VK code.
downbool, optional = true
true = press, false = release.
modifierstable, optional = {}
Held modifiers: {"shift", "control", "alt"}.

Returns

true when the key was sent; false for an unknown name.

Example

-- Ctrl+A w aktywnym polu strony
injectBrowserKey(browser, "a", true, { "control" })
injectBrowserKey(browser, "a", false, { "control" })

Notes

The player's keyboard reaches the page by itself when the browser has focusBrowser, the cursor is visible and a text field on the page is active. This function is for shortcuts and driving the page from a script.

See also