C
carlos
The below code listens to key combinations in my app. I am using
prototype (not my decision), but I am open to using other
alternatives. The problem i'm having is that when using Event.observe
to listen for key combinations it doesn't always catch my key strokes.
If I press on one of the tabs in my app, it listens again. These tabs
represent the content pages in my app, which are dynamically
generated, and are iframe elements. I believe that has
somethign to do with it, but i'm not familiar with prototype or the
Event Model all that much. Any help would be appreciated! See my code
example below.
Event.observe(window, 'load', function() {
Event.observe(document, 'keypress', function(e){
//listen for key events
var targ = e ? e : window.event;
key = targ.keyCode ? targ.keyCode : targ.charCode;
//handle combination
if(targ.altKey == true && (key == 67)) {
HandleEvent(key);
}
});
prototype (not my decision), but I am open to using other
alternatives. The problem i'm having is that when using Event.observe
to listen for key combinations it doesn't always catch my key strokes.
If I press on one of the tabs in my app, it listens again. These tabs
represent the content pages in my app, which are dynamically
generated, and are iframe elements. I believe that has
somethign to do with it, but i'm not familiar with prototype or the
Event Model all that much. Any help would be appreciated! See my code
example below.
Event.observe(window, 'load', function() {
Event.observe(document, 'keypress', function(e){
//listen for key events
var targ = e ? e : window.event;
key = targ.keyCode ? targ.keyCode : targ.charCode;
//handle combination
if(targ.altKey == true && (key == 67)) {
HandleEvent(key);
}
});