diff --git a/scriptedbrowser/commands/base.php b/scriptedbrowser/commands/base.php index c19a1e7..5aef090 100644 --- a/scriptedbrowser/commands/base.php +++ b/scriptedbrowser/commands/base.php @@ -23,6 +23,21 @@ function injectjscript($main, $control, $options) return true; } +/** + * press given key + * + * @param \ScriptedBrowser\Main $main + * @param \ScriptedBrowser\Control $control + * @param array $options options + * @return bool always true + */ +function key($main, $control, $options) +{ + $key = $main->vars($options['parameter']); + $control->key($key); + return true; +} + /** * do mouse left click * diff --git a/scriptedbrowser/control.php b/scriptedbrowser/control.php index 1a6a43e..f65e24e 100644 --- a/scriptedbrowser/control.php +++ b/scriptedbrowser/control.php @@ -184,6 +184,16 @@ class Control return $this->executeScript('return [window.pageXOffset, window.pageYOffset];'); } + /** + * press given key (combination) + * + * @param string $key key to press + * @return void + */ + public function key($key) + { + fwrite($this->xdotool, "key $key\n"); + } /** * move mouse to absolute position *