Double Key Press Activation State Machine Thingy!

I’m working on building a documentation search tool based on QuickSilver and Alfred App. I needed a way to activate the search so I built this demo in preparation for finishing the search tool. You can check out the live demo at

This is what it looks like even though the code is the fun part:

The demo code will shift states as you press the ‘s’ key. If you press the ‘s’ key quickly enough back to back it will switch to the activated state and stay there until the ‘esc’ key is pressed causing it to reset. The code also won’t change state if the focus is in a textarea or input to prevent activation while a user is typing in an area they don’t want to be interrupted in. I will have to add an exception for the search tool input box when I implement this to allow the ‘esc’ key to reset and hide the search tool while inside of it. You can use the code if you like and I would love to hear any feedback that anyone has about it.

Tested on Mac 10.6.6 with Firefox 3.6, Chrome 9.0, Safari 5.0, and Opera 11.01

Published by


I am a Geek! I hope you enjoyed this recent post.