Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Keystroke event
- From: elmuchacho at gmail.com (Laurent Muchacho)
- Subject: [Javascript] Keystroke event
- Date: Fri Mar 24 07:00:38 2006
Hi Nick,
Yes this is what I thought originally and try this approach but with no
success.
I didn't know about the preventDefault method but this, neither seems to be
able to stop the default save as window to open.
Many thanks for your help
If anyone got an idea let it come :-)
function keyDown(e) {
if(e.ctrlKey){
document.onkeydown = trigger_ctrlS;
}
}
function trigger_ctrlS(e){
var keycode = e.which
if(keycode==83){
alert("ctrl s");
return false
}
}
document.onkeydown = keyDown
Laurent
On 3/24/06, Nick Fitzsimons <nick@xxxxxxxxxxxxxx> wrote:
>
> > Hi
> >
> > Does anyone know a good reference or have a nice examples to catch the
> > keystroke ctrl+s in the browser
> > I wrote this simple function but everytime the browser try to do a save.
> >
> <snip>
> >
> > function keyDown(e) {
> > var keycode = e.which
> > if(keycode==17){
> > document.onkeydown = trigger_ctrlS;
> > return true
> > }
> > }
> > function trigger_ctrlS(e){
> > var keycode = e.which
> > if(keycode==83){
> > alert("ctrl s: ")
> > document.onkeydown = keyDown
> > return true
> > }
> > }
> > document.onkeydown = keyDown
>
>
> The usual way of cancelling the default action for an event is to return
> false from the event handler; try changing your "return true;" in the
> above to "return false;" and see if that helps.
>
> If that doesn't work, as you say it's for Firefox, try visiting the
> Firefox/Mozilla developers site:
> <http://developer.mozilla.org/en/docs/DOM:event#Introduction>
> explains the "preventDefault" method, which might do what you want.
>
> HTH,
>
> Nick.
> --
> Nick Fitzsimons
> http://www.nickfitz.co.uk/
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.LaTech.edu/pipermail/javascript/attachments/20060324/8b283b5a/attachment.html
- Follow-Ups:
- [Javascript] Keystroke event
- From: J. Lester Novros II
- [Javascript] Keystroke event
- References:
- [Javascript] Keystroke event
- From: Laurent Muchacho
- [Javascript] Keystroke event
- From: Nick Fitzsimons
- [Javascript] Keystroke event
- Prev by Date: [Javascript] Keystroke event
- Next by Date: [Javascript] Keystroke event
- Previous by thread: [Javascript] Keystroke event
- Next by thread: [Javascript] Keystroke event
- Index(es):