Extending event handling safely, and protectedly
<p>I am writing a small JavaScript library, and in it, I have components that need to receive "messages" when certain page events go off, and allow users to supply response functions. Basically, I need to access the general events, such as <code>onkeydown</code>, and the user can supply how a component will handle it.</p>

<p>Setting a callback like this is easy. The problem I face though, is when I consider the possibility of other libraries and user code working at the same time. I have to not only preserve their existing handling, but make it flexible afterwards too, since someone could just overwrite what I've done.</p>

<p>Is there any patterns or suggestions that could be used here so all code could work in union? I hope I'm making sense with this one. I can provide more details, if needed.</p>
