| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Holosuit User
|
Hi, somehow I cannot find how to prevent these specific keysequences from their default behavior (Ctrl+O, Ctrl+P, Ctrl+F).
It seems like any other button can be prevented, but not these... My first guess was that those are hardcoded, but it's not so, somehow Google Documents can open a pop-up when user hits Ctrl+O. So, maybe there is some workaround, maybe in VBScript?.. My code so far: HTML Code:
<script type="text/javascript"> <!--// function f() { document.kp = function(e) { var fl = document.getElementById("out"); fl.keyevt({t:e.type, k:e.keyCode}); e.preventDefault(); e.stopPropagation(); return false; } document.ku = function() { var e = window.event; e.cancelBubble = true; e.returnValue = false; if (e.stop !== undefined) e.stop(); var fl = document.getElementById("out"); fl.innerHTML = e.type; return false; } if (document.addEventListener !== undefined) { document.addEventListener("keydown", document.kp, true); document.addEventListener("keyup", document.kp, true); } else { document.onkeyup = document.ku; window.onkeyup = document.ku; document.onkeydown = document.ku; window.onkeydown = document.ku; document.onkeypress = document.ku; window.onkeypress = document.ku; } } f(); //--> </script>
__________________
The .NET open source editor for Flash and web developers *This would be my contribution to the project* couchsurfing if you need it |
|
|
|
|
|
#2 |
|
jordanrift.com
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
|
Not sure it's going to happen. All you really need to do is return false (e.preventDefault(), etc aren't needed). However, I think IE sees those key presses and passes them through to the OS. Not sure there's much you can do to supress that.
|
|
|
|
|
|
|
|
|
#3 |
|
Holosuit User
|
Well, how then Google Documents do it? They definitely do it using JavaScript...
You can prevent Explorer .NET control from that behavior without recompiling it, that I know for certain... but, no idea how to do that / how Google are doing it using JS... preventDefault is for DOM2 browsers, it's not called when in IE...
__________________
The .NET open source editor for Flash and web developers *This would be my contribution to the project* couchsurfing if you need it Last edited by wvxvw; 11-02-2009 at 09:34 PM.. |
|
|
|
|
|
#4 | |
|
jordanrift.com
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
|
Quote:
I've had IE7 choke on e.preventDefault() before, so I don't think it gets ignored completely, though that might have been an IE problem with jQuery. Just brought it up as a caution. In my experience, it hasn't given me any benefit over just returning false. |
|
|
|
|
|
|
#5 |
|
jordanrift.com
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
|
I'm stumped, honestly. I've tried every way I know how, but I can't seem to suppress those commands (Ctrl + C, V, F, O, or P) in IE. I can in Firefox or webkit browsers, but not IE. Seems to be one of Google's best kept secrets...
![]() |
|
|
|
|
|
#6 |
|
Holosuit User
|
Actually, I have an idea... need to check it though... what if on Ctrl you move focus to some, say, <inpupt> or <textarea> and then in that component wait for the next key?.. Or just dispatch fake key event in between?
maybe it will trick it out of opening that window... I'll check in the evening and we'll see... Debugging Google code is really impossible. ![]()
__________________
The .NET open source editor for Flash and web developers *This would be my contribution to the project* couchsurfing if you need it |
|
|
|
|
|
#7 |
|
jordanrift.com
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
|
That's an interesting approach. Let me know how that turns out. If that works, I could see engineering that into a fairly portable shortcut framework.
Agreed. They do a fantastic job at obfuscating their JS. ![]() |
|
|
|
|
|
#8 |
|
Holosuit User
|
Nope, neither of them two worked
![]() The closest I can get is to cause some error in between capturing Ctrl and O... but this doesn't sound like a way to go... Even if for example you hit Ctrl+Shift+O the dialog won't open, but if you fake the Shift button, then the dialog opens anyway, even though the Shift is displayed as pressed. Moving focus anywhere doesn't work either... Besides, I don't think I have managed to crash IE so many times in a row, as I did that today
__________________
The .NET open source editor for Flash and web developers *This would be my contribution to the project* couchsurfing if you need it |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|