Skip to content

Keyboard Functions

Oğuzhan edited this page Sep 28, 2023 · 1 revision

To easily use the keyboard:

const {keyboard} = jsautogui // jsautogui has to be defined
// or
import {keyboard} from "jsautogui" // modulejs
// or
const {keyboard} = require("jsautogui") // commonjs

.press(key1, key2...)

Presses a button on the keyboard.

keyboard.press("a")

keyboard.press("a", "shift")

.down(key1, key2...)

Presses a button down on the keyboard and doesn't release back.

keyboard.down("a")

keyboard.down("a", "shift")

.up(key1, key2...)

Releases a buttpn on the keyboard.

keyboard.up("a")

keyboard.up("a", "shift")

.write(text1, text2...)

Writes text for the keyboard.

keyboard.write("Hello, world!")

keyboard.write("Hello, world!", "I am alive!")

.hotkey(key1, key2...)

Presses as a hotkey. First presses down all keys and releases them back up after pressing them all down.

keyboard.hotkey("control", "c")
keyboard.hotkey("control", "v") // you are now officially a programmer