Recording all keystrokes

120 views
Skip to first unread message

da...@thedavid.co.uk

unread,
Apr 19, 2016, 12:20:01 PM4/19/16
to Hammerspoon
Many utilities provide a history of what's been copied to the clipboard (e.g. Alfred). I'd like to do something similar: provide a history of everything that's been typed, to be able to search/reinsert it easily.

It would do something like this:

1) Record all keystrokes and append them to a string
2) Chop up the string into a new 'phrase' every time:
- A modifier key is pressed
- An arrow/tab key is pressed
- The mouse is clicked
3) Store all the phrases in chronological order somewhere
4) Show a UI that displays the most recent phrases and allows pasting them into the current context

Is this something that Hammerspoon could do? If so, any tips on where I should start?

Chris Jones

unread,
Apr 19, 2016, 12:21:28 PM4/19/16
to da...@thedavid.co.uk, Hammerspoon
Hi

You'll want to use hs.eventtap to get notified of all keystrokes and mouse clicks, and hs.chooser to display them :)

Cheers,
Chris

--
You received this message because you are subscribed to the Google Groups "Hammerspoon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hammerspoon...@googlegroups.com.
To post to this group, send email to hamme...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/hammerspoon/dbf8b403-8070-471c-b507-95b459c8da78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Roberts

unread,
Apr 20, 2016, 12:12:07 PM4/20/16
to Chris Jones, Hammerspoon
Thanks for this, Chris – I've managed to get a basic version up and running.

One issue I'm running into is that when dismissing the chooser, the previous window doesn't regain focus - making it hard to insert any text.

Is this something that you've come across before?

David

David Roberts

unread,
Apr 20, 2016, 12:49:47 PM4/20/16
to Chris Jones, Hammerspoon
(OK, I got around it by saving the last focused window before displaying the chooser, then restoring it afterwards)


Szymon Kaliski

unread,
Apr 25, 2016, 12:16:43 PM4/25/16
to Hammerspoon, cm...@tenshu.net, da...@thedavid.co.uk
Hey David, this sounds like really cool idea, could you share the code in gist somewhere? Would love to have a look! :)
Reply all
Reply to author
Forward
0 new messages