I'm guessing you already have a tool observer set up or something? You've already figured out how to keep track of the previously used tools, right? If so,
Lets say you have a global variable that holds an array of all the last used tools - $previous_tools
Also, maybe you need a menu item for "Set Shortcut Key". This is for the user to tell your script what key they have assigned your script to (it might save the value to an external text file or a registry entry would be better). So perhaps they assign it to "t", your inputbox could create a global variable $previous_tools_shortcut = "t"
Now make a tool with the onKeyUp method in it. It compares the onkey up to $previous_tools_shortcut. And it also implements its own timer feature. So you can watch the time between keystrokes. So if they press the dhortcut key 1 time, it just selects $previous_tools.last. If they press it twice within a specified time limit (.5 seonds or less) then it will select $previous_tools[length-1], press it three times within 1 second, it selects the $previous_tools[length-2] tool.
That is how I think I would go about it. But that assumes you have an array of the previously used tools, and it also requires the user to input the shortcut key that they assigned to your tool.
Chris