GithubHelp home page GithubHelp logo

key2mod's Introduction

key2mod

Use a normal key as a modifier, e.g. Space acts as Control when pressed with a second key, but as Space when pressed alone. Tested on Linux, might work on *BSD if libevdev is available.

Installing

  • Make sure you have libevdev installed, on certain distros (e.g. Ubuntu) a dev package is required
  • Clone this repository, build and install with
make
sudo make install

Usage

Access to /dev/input/* and /dev/uinput is required, this can be achieved by running this as root. Basic usage:

key2mod -e <eventfile> -k <key> -m <modifier>

Replace with the appropriate file for your keyboard in /dev/input (/dev/input/by-id makes finding the correct file easy), and with the keynames like KEY_SPACE or KEY_LEFTCTRL. These names can be optained by running evtest <eventfile>. Use the option -f to run in the background. Example:

key2mod -e /dev/input/event0 -k KEY_SPACE -m KEY_LEFTCTRL -f

When receiving SIGINT or SIGTERM cleanup is performed and the program exits.

How it works and limitations

This program reads all events coming from the keyboard, all events that are not <key> pressed are passed through to uinput. When <key> pressed is received, it waits for either any other key to be pressed or <key> to be released, to send the appropriate events to uinput.

This means that pressing the used key alone will generate the event at the release, which makes this unsuitable for games or other applications where timing is important. Also when trying to input a combination like shift+ctrl+key the normal modifier needs to be pressed first as otherwise the combination of modifiers and the key will be send separately.

key2mod's People

Contributors

dokutan avatar

Stargazers

 avatar  avatar

Watchers

 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.