Suppose you have the following structure in your HTML and some elements inside the content div have various key (press, up, down) events:
<html>
<head></head>
<body>
<div id="content">All the content</div>
</body>
</html>
You add an absolute positioned div by jQuery:
$('body').append('<div id="lightbox">etc.</div>');
How can you temporarily (during the existance of the lightbox) prevent all keyboard events from being caught by or bubbled to only $('#content')
and its children, so that the bubbling order when the lightbox exists for the above structure will be
$('#lightbox *')
$('#lightbox')
$('body')
$('html')
whereas it will be
$('#content *')
$('#content')
$('body')
$('html')
when the lightbox is gone?
EDIT: Here's some extra info.
I can't make all the form elements disabled or readonly (this applies to limited elements anyway) because lightbox may occasionally exist on top of many form elements that have already assigned unique key events.
Also, I want key events to affect window + (lightbox, if any, otherwise content) so I can't just stop all event propagation directly
The orders above can be 4-1 instead of 1-4, it doesn't matter. What matters is to bypass the contents of this specific element (lightbox or content acc. to the situation) in key events.