Skip to content
Package for Golang. Emulate keyboard input from string.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
.gitignore
keys_darwin.go
keys_linux.go
keys_windows.go
readme.md
string2keyboard.go

readme.md

string2keyboard

Emulate keyboard input from string

Overview

Package is used to emulate keyboard input. It is generates keystrokes on the keyboard and sends them to the active text input field. So cursor should be in some text input field before calling KeyboardWrite method. Escape sequences are available for some special characters ('Tab', 'Enter' etc.)

Install

go get github.com/taglme/string2keyboard

Import

import (

    "github.com/taglme/string2keyboard"

)

Usage

message := "Hello world!"
err := string2keyboard.KeyboardWrite(message)

Special characters

It is possible to pass some special characters using escape sequence. Use backslash character to start escape sequence. List of available special characters:

  • \n - line feed or newline
  • \b - backspace
  • \t - horizontal tab
  • \\ - backslash
  • \" - double quote

Basic example

Check usage in example folder.

Special characters example

//Newline example
message := "123\n456"
err := string2keyboard.KeyboardWrite(message)

//Output
123
456

//Tab example
message := "123\t456"
err := string2keyboard.KeyboardWrite(message)

//Output
123   456

//Backslash example
message := "123\\456"
err := string2keyboard.KeyboardWrite(message)

//Output
123\456
You can’t perform that action at this time.