myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <mkien...@gmail.com>
Subject Re: F5 Keycode is not available in javascript
Date Tue, 18 Sep 2007 15:30:11 GMT
Back when I was working on this, I came up with a custom component
that could trigger either a javascript or JSF action for each function
key (actually, any key):

Here's some of the code from the renderer:

        writer.write("\n");
        writer.startElement("script", component);
        writer.writeAttribute("language", "javascript", null);
        writer.write("\n");
        writer.write("// <![CDATA[\n");

        if (onKeyDownComponent.isRegisteredKey(KeyCombination.KEY_F1))
        {
            // Use this to over-ride F1 default function of help pop-up window.
            // F2 -> F12 need no such special case handling.
            //
            // document.onhelp = function (){
            //     event.cancelBubble = true;
            //     event.returnValue = false;
            // }

            writer.write("document.onhelp = function (){\n");
            writer.write("    event.cancelBubble = true;\n");
            writer.write("    event.returnValue = false;\n");
            writer.write("    if (e.stopPropagation) e.stopPropagation();\n");
            writer.write("}\n");
            writer.write("\n");
         }

        writer.write("document.onkeydown = location_redirect;\n");
        writer.write("function location_redirect(e) {\n");
        writer.write("  if (!e) var e = window.event;\n");
        writer.write("  if (e.keyCode) code = e.keyCode;\n");
        writer.write("  else if (e.which) code = e.which;\n");
        writer.write("  switch (code) {\n");


On 9/18/07, Andrew Robinson <andrew.rw.robinson@gmail.com> wrote:
> If it works at all, I'm sure that keyup will definitely not work. Try
> onkeydown. I know I can capture F1 in the key down in FF and the FF
> help will not open
>
> On 9/18/07, Chetan Bob <chetanpadhye@gmail.com> wrote:
> >
> > Hi
> >
> > <script type="text/javascript">
> > document.onkeyup = KeyCheck;
> >
> > function KeyCheck(e)
> >
> > {
> >
> >    var KeyID = (window.event) ? event.keyCode : e.keyCode;
> >
> >
> >    switch(KeyID)
> >
> >    {
> >
> >       case 116: {
> >                                 event.keyCode = 0;
> >                                 event.returnValue = false;
> >                                         document.forms['myForm'].submit();
> >                                 break;
> >                  }
> >
> >           case 16:
> >
> >                                         window.location ="http://www.yahoo.com";
> >            break;
> >
> > }
> >  }
> >
> >
> > Hear I cant get case 116 which is F5 Refresh keycode ....other than
> > functionkey code are ok like 16 of shift button ....
> >
> > Also
> > document.forms['myForm'].submit();
> >
> > is seems not working it says error myForm Dosent have submit attribute ..
> >
> > --
> > View this message in context: http://www.nabble.com/F5-Keycode-is-not-available-in-javascript-tf4471972.html#a12750800
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>

Mime
View raw message