Code Monkey home page Code Monkey logo

gokbd's Introduction

gokbd

GitHub Go Reference gokbd codecov

About

gokbd is a package that uses libevdev to talk to a keyboard on Linux. It allows snooping the keys pressed as well as typing out keys.

Usage

import gokbd "github.com/joshuar/gokbd"

Examples for reading what keys are being typed (snooping) and writing to a virtual keyboard are available under the examples/ directory. To run them:

cd examples/snoop
go build
sudo setcap cap_setgid,cap_setuid=p ./snoop
./snoop

cd examples/type
go build
sudo setcap cap_setgid,cap_setuid=p ./type
./type

Permissions

You may need to grant additional permissions to the user running any program using gokbd.

  • To read (snoop) from keyboards, the user will need to be part of the input group. Typically, the user can be added with the following command:
sudo gpasswd -a $USER input
  • To create a virtual keyboard and write to it, the user will need access to the kernel uinput device. Typically, this can be granted with a udev rule like the following:
echo KERNEL==\"uinput\", GROUP=\"$USER\", MODE:=\"0660\" | sudo tee /etc/udev/rules.d/99-$USER.rules
sudo udevadm trigger

You will also need to grant your compiled binary the CAP_SETUID and CAP_SETGID Linux capabilities. You can do this with:

sudo setcap cap_setgid,cap_setuid=p /path/to/binary

gokbd's People

Contributors

github-actions[bot] avatar joshuar avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.