8
\$\begingroup\$

Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG.

  1. The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome).
  2. Upon execution, it has to show the message: "I'm gonna log you" (either in a console or using GUI).
  3. The keys that are relevant for logging in this challenge are letters (case is not important) and numbers, all others such as symbols, control keys and whitespace are optional and can be ignored.
  4. All relevant key presses that occur during runtime (even when the application is not in focus) have to be saved in a log file that can be read and verified using any text editor (even an esoteric one, as long as I can verify it using that text editor).

Anyone up for it? Whatdayatink?

\$\endgroup\$
  • 1
    \$\begingroup\$ "4. [...] saved in a log file" in what format? \$\endgroup\$ – Leaky Nun Apr 3 '16 at 16:23
  • \$\begingroup\$ Updated my question to specify intended format. \$\endgroup\$ – MathuSum Mut Apr 3 '16 at 16:25
  • \$\begingroup\$ I can easily log what is typed in my program's REPL, is that sufficient or should it work work when I type anything in my browser or any other application too? \$\endgroup\$ – coredump Apr 3 '16 at 16:30
  • \$\begingroup\$ Yes, it should work for anything, "even when the application is not in focus". \$\endgroup\$ – MathuSum Mut Apr 3 '16 at 16:32
  • 1
    \$\begingroup\$ Can we write a program that runs on mac (AppleScript), if we provide an example gif of it running? \$\endgroup\$ – Downgoat Apr 3 '16 at 19:02
10
\$\begingroup\$

Bash, 90 bytes

This works on Ubuntu, and requires evtest. It picks a device that is a keyboard, and saves evtest's output to the file l. If you want a more formatted output, I can do that with more bytes.

echo I\'m gonna log you
sudo evtest /dev/input/by-path/`ls /dev/input/by-path/|grep kbd`>l
\$\endgroup\$
  • 1
    \$\begingroup\$ You sir deserve respect. \$\endgroup\$ – MathuSum Mut Apr 4 '16 at 5:57
5
\$\begingroup\$

AutoHotKey, 1171 bytes

Yes, it's insanely large, but it does the job.

#NoEnv ;
SendMode Input ;
ToolTip, I'm gonna log you!

~a::fileappend, a, keylog.txt
~b::fileappend, b, keylog.txt
~c::fileappend, c, keylog.txt
~d::fileappend, d, keylog.txt
~e::fileappend, e, keylog.txt
~f::fileappend, f, keylog.txt
~g::fileappend, g, keylog.txt
~h::fileappend, h, keylog.txt
~i::fileappend, i, keylog.txt
~j::fileappend, j, keylog.txt
~k::fileappend, k, keylog.txt
~l::fileappend, l, keylog.txt
~m::fileappend, m, keylog.txt
~n::fileappend, n, keylog.txt
~o::fileappend, o, keylog.txt
~p::fileappend, p, keylog.txt
~q::fileappend, q, keylog.txt
~r::fileappend, r, keylog.txt
~s::fileappend, s, keylog.txt
~t::fileappend, t, keylog.txt
~u::fileappend, u, keylog.txt
~v::fileappend, v, keylog.txt
~w::fileappend, w, keylog.txt
~x::fileappend, x, keylog.txt
~y::fileappend, y, keylog.txt
~z::fileappend, z, keylog.txt
~1::fileappend, 1, keylog.txt
~2::fileappend, 2, keylog.txt
~3::fileappend, 3, keylog.txt
~4::fileappend, 4, keylog.txt
~5::fileappend, 5, keylog.txt
~6::fileappend, 6, keylog.txt
~7::fileappend, 7, keylog.txt
~8::fileappend, 8, keylog.txt
~9::fileappend, 9, keylog.txt
~0::fileappend, 0, keylog.txt
\$\endgroup\$
  • \$\begingroup\$ Creative, didn't occur to me to use a hotkey monitor :P \$\endgroup\$ – MathuSum Mut Apr 14 '16 at 16:19
  • \$\begingroup\$ The log file's name can be a single character saving you 9 bytes per key. You should be able to iterate over all of the keys in a for loop, saving you many, many, many bytes. As it stands, I'm not convinced this answers meets our serious contender criteria. \$\endgroup\$ – Mego Aug 15 '16 at 9:18
  • \$\begingroup\$ According to the rules in our help center, all solutions must be a serious contender for the winning criteria in use. For a code golf contest, that means all entries must show some attempt at golfing the code. \$\endgroup\$ – Dennis Aug 15 '16 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.