Back in a Bit

Handling Keyboard Shortcuts Within Modular JavaScript Application Architecture

Yesterday, when using Gmail, I started to think about keyboard shortcuts. Specifically, I started to think about how keyboard shortcuts get routed within a modular JavaScript application architecture. If I have a module that can respond to the keyboard – but, that module is not supposed to “know” about the document at large – how does it listen for key-based events? I can think of two ways: 1) Either the application listens for keys and then directly invokes methods on encapsulated modules; or 2) the application listens for keys and then announces key events using an intermediary sandbox. While my gut tells me the former is more effective, I’ve never really used a sandbox bridge; as such, I thought I’d experiment with the latter.