How do I track a "held" key in an extension?

I am making an extension that will only apply to the editor when a certain key is being held down. What do you think the best approach would be for storing the key press state in a way the extension would have access to it?