nhmkdev / KeyCap

A Windows application for remapping keyboard input.
MIT License
48 stars 7 forks source link
accessibility capture-keyboard keyboard keyboard-shortcuts keycaps keystrokes mouse mouse-emulation mouse-events remap remapping remapping-keyboards windows

KeyCap

Download the Latest Release

Description

Windows only application for capturing keyboard input and remapping it to:

Example Uses

Run on Startup

With Registry Editor, add a new StringValue to HKCU\Software\Microsoft\Windows\CurrentVersion\Run with the full path to KeyCap.exe followed by the full path to your .kfg file. KeyCap will load the config file, start it and then minimize to the tray.

Alternatively, copy the following to a text file named KeyCap.reg and then edit it to match your setup. Save it, right click-it and selct Merge. Follow the prompts and then the next time you reboot, KeyCap will start automatically.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"KeyCap"="D:\\Util\\KeyCap\\KeyCap.exe -f D:\\Util\\KeyCap\\Config.kfg"

You can also include the -autostart argument if you wish to immediately start capturing keys with the loaded config.

Warning

This program does perform keyboard capture and is essentially the first component of a key logger. I humbly request you NOT use the information included in the source code to create a malicious application.

Visual Studio Notes

Technical Documentation

Library File Naming and Organization

.kfg File Format

The file is prefixed with two 32-bit ints:

File Data Prefix File Format Version
0x0E0CA000 0x1

The remainder of the file is a repeated sequence of the following information. One input may be associated with numerous outputs.

Byte array representation of each input/output(s) pair:

(#) is the number of bytes the given information is alloted.

Input Bytes Input Flags (4) Input VirtualKey (1) Padding (3) Parameter (4) Outputs Count (1) Padding (3) (all outputs for input)
Output Bytes Output Flags (4) Output VirtualKey (1) Padding (3) Output Parameter (4)

There is no count for the number of inputs. Instead the file is read until no further input/output(s) pairings can be read.

Flags

The flags indicate information that modifies the value (alt/shift/ctrl and special functionality when mapping to another output)

VirtualKey

A VirtualKey value.

Parameter

A special value associated with the input/output (as necessary based on the function).

Output Count

This is limited to a single byte despite the use of an int, so 255 maximum.

History

Used to be called Key2Key but then I added mouse support so that name needed to change.

Disclaimer

I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer.