- Documentation
- Client functions
- injectBrowserKey
Function
injectBrowserKey
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 = truetrue= 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
injectBrowserCharacterTypes text into the page's active field, character by character (keypress/inputevents), including accented letters and other UTF-8 characters.focusBrowserGives the keyboard to a browser. Typing goes to the page when one of its text fields is active and the cursor is shown.nilremoves focus from all browsers.injectBrowserMouseDownPresses a mouse button on the page at the position of the lastinjectBrowserMouseMove. Two presses at the same spot within 0.5 s reach the page as a double click, three as a triple click (paragraph selection), like in Windows.