Forums > MaxMSP

Creating a Keyboard Logger Help

Jan 29 2011 | 7:07 pm

I’ve been trying to create a keyboard stroke logger for the past days, and i managed to record into max window every stroke while max is selected through the key function and the printing it out to the max window. The problem is that I need max to keep recording the strokes used whilst on background.
I tried using the hi function but it only logs numbers, not the letters.
Can you guys help me out here?
Here’s what i’ve got so far:

-- Pasted Max Patch, click to expand. --


Jan 29 2011 | 10:43 pm

You will need to use [hi] instead of [key]. Look into something like [itoa] although you might need to use some basic maths or create a custom [coll] to do the mapping for you.

Jan 29 2011 | 11:34 pm

try this. I`m sure there is a smarter way doing this. But it is working.
I only did it for three keys so it may take a while to figure out and program all the other keys.
You can then use [text] to save the keystrokes as a textfile.

— Pasted Max Patch, click to expand. —


Jan 30 2011 | 9:03 am

here is the optimized version of the patch.
Just create the numbers + ASCII Code for all the keys in a text file in [coll].
Not working at the moment is shift/alt/cmd/F1….F12.

— Pasted Max Patch, click to expand. —
Jan 31 2011 | 1:52 am

Thanks guys you are really helping.
I managed to map almost all the keyboard using spray.
but now it prints everything doubled. i mean, the "key in" and "key out".

any clues on how to filter this to only show one stroke and not everything doubled?
Here’s the patch

-- Pasted Max Patch, click to expand. --

Jan 31 2011 | 4:11 pm

I made some improvements.
Its now possible to write the log into a text file and save incl. date&time.

If you want avoid the double printing in your patch use [togedge].
See my patch for example.
To use the patch copy the two .txt files attached to a folder on your HD and use ->options -> file preferences – to include the path of the folder in which you copied the files.


  1. keylist.txt
Jan 31 2011 | 4:17 pm

Its not possible to upload the other .txt file.
just create an empty one and call it keylogfile.txt

Jan 31 2011 | 6:33 pm

you patch keeps loggin cmdR and nothing else :S

Jan 31 2011 | 7:13 pm

its working fine here…did you try different settings in umenu?
change to another keyboard?
is max missing the keylist.txt file?
what system are you running max?
pc or win?

Jan 31 2011 | 11:12 pm

i’m running max on a mac. yes i did try different settings on the menu, tried all keyboards and max is not missing any keylist.txt file.

Feb 01 2011 | 9:38 am

check if file keylist.txt is empty.
check if the numbers of your keyboard shown in [key] and [print keynumber] match in keylist.txt.
if not, add the numbers matching your keyboard.
open keylogfile.txt. see if there is logtext (or even date and time) in this file.
upload a screenshot of the patch.

Viewing 11 posts - 1 through 11 (of 11 total)

Forums > MaxMSP