I just started working on a tool to help me increase my productivity with Vim. I want it to log every keystroke to a file and then identify inefficient usage patterns. I would like it to store a timestamp for every keystroke.
I've tried using the -w and -W vim options to dump every keystroke to a pipe. However, Vim doesn't report keystrokes on-line and so I could not obtain reliable timestamps.
I've also tried intercepting input from a tty, writing it to a pipe and redirecting it as stdin for Vim. But then Vim just quits with:
Vim: Warning: Input is not from a terminal
I've also found this trick to capture every key: http://vim.wikia.com/wiki/Capture_all_keys. I don't know anything about vimscript, but I get a feeling that's not what I'm looking for.
So my thinking now is: I need to intercept input from a tty, process it and then write it to some fake tty that Vim will use as an input. Would you agree that's the best approach to take? If so, any hints on how I could do that?
Short for “keystroke logging,” a keylogger is a type of malicious software that records every keystroke you make on your computer. Keyloggers are a type of spyware — malware designed to spy on victims. Because they can capture everything you type, keyloggers are one of the most invasive forms of malware.
It has a capacity of up to 2,000,000 keystrokes stored with STRONG 128-bit encryption.
Key Logging is the process of storing keystrokes with/without the knowledge of user. Keylogging can be hardware based as well as software based. As clear from the name, a hardware based keylogger does not depends upon any software and keystroke logging is done at hardware level itself.
After digging a bit more and looking into 'script' sourcecode, I found this:
man 7 pty
man 4 pts
man 3 openpty
Creating a new pseudo-terminal seems like the way to go here and I'm going to give it a shot.
Edit: It seems to be working. In case someone runs into similar issue, the project can be found at https://github.com/Baranowski/habit-vim/.
A possible approach could be to patch the Vim code : in the loop, where keyboard inputs are captured, save them, and write them to your file. (or you could somewhow add them to the .viminfo
)
https://code.google.com/p/vim/source/browse/src/gui.c
It seems that the following function is waiting to get input from the user.
int gui_wait_for_chars(wtime)
So you might be able to find the entry point for keyboard input from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With