Skip to content

Keyboard Functions

Oğuzhan edited this page Jul 21, 2025 · 2 revisions

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. Check All Keys.

keyboard.press("a")

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

.down(key1, key2...)

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

keyboard.down("a")

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

.up(key1, key2...)

Releases a buttpn on the keyboard. Check All Keys.

keyboard.up("a")

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

.write(text1, text2...)

Writes text for the keyboard. Check All Keys.

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. Check All Keys.

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

All Keys

You can give in any ASCII or Unicode character as a key.

And here's a list of all possible modifier keys:

accept, add, alt, altleft, altright, apps, backspace, browserback, browserfavorites, browserforward, browserhome, browserrefresh, browsersearch, browserstop, capslock, clear, convert, ctrl, ctrlleft, ctrlright, decimal, del, delete, divide, down, end, enter, esc, escape, execute, f1, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f2, f20, f21, f22, f23, f24, f3, f4, f5, f6, f7, f8, f9, final, hanguel, hangul, hanja, help, home, insert, junja, kana, kanji, launchapp1, launchapp2, launchmail, launchmediaselect, left, modechange, multiply, nexttrack, nonconvert, num0, num1, num2, num3, num4, num5, num6, num7, num8, num9, numlock, pagedown, pageup, pause, pgdn, pgup, playpause, prevtrack, print, printscreen, prntscrn, prtsc, prtscr, return, right, scrolllock, select, separator, shift, shiftleft, shiftright, sleep, space, stop, subtract, tab, up, volumedown, volumemute, volumeup, win, winleft, winright, yen, command, option, optionleft, optionright