Web Analytics Made Easy -
StatCounter On screen buttons, acting like a keyboard - CodingForum

Announcement

Collapse
No announcement yet.

On screen buttons, acting like a keyboard

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • On screen buttons, acting like a keyboard

    I have several buttons made to reflect an onscreen keyboard. I also have several input forms above them. I want the user to click on any of the buttons and have them fill in the forms with out the keyboard. Only using the mouse or a touch screen. Is this possible with javascript.
    If you don't do it this year, you will be one year older when you do. "Warren Miller"

  • #2
    yes. but it would probably end up being more code than its worth.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

    Comment


    • #3
      humm

      you could even take a photograph of the keyboard and use an image map if you wanted to....

      -S. Bob

      Comment


      • #4
        this ok?

        here's a rough idea. it allows the user to press the buttons and their value will be added to the current text box. if they click another text box, that will be set as 'vCurrent' and will be typed into. Use your existing buttons, just stick onclick="fType(insert key here)" into their tags. also use your existing text boxes, just make sure you give them names of field1, field2 etc. or the selection thing won't work.

        you will need a backspace button and it might be nice to be able to insert text partway through a field. i haven't done this cos i dont know exactly what you need.

        Code:
        <HTML>
        <HEAD>
        <TITLE>typing thing</TITLE>
        <SCRIPT language=javascript>
          <!--
          var vCurrent = 1
          function fType(keyPressed){ //adds the value of the pressed button to the field.
            eval("document.frmStuff.txtField" + vCurrent + ".value += keyPressed")
          }
          //-->
        </SCRIPT>
        </HEAD>
        <BODY>
        <FORM name=frmStuff>
          <P><INPUT type=text name=txtField1 size=50 onclick="vCurrent = 1"></P>
          <P><INPUT type=text name=txtField2 size=50 onclick="vCurrent = 2"></P>
          <P><INPUT type=text name=txtField3 size=50 onclick="vCurrent = 3"></P>
          <P>
            <INPUT type=button name=btnKeyQ value="Q" onclick="fType('Q')">
            <INPUT type=button name=btnKeyW value="W" onclick="fType('W')">
            <INPUT type=button name=btnKeyE value="E" onclick="fType('E')">
            <INPUT type=button name=btnKeyR value="R" onclick="fType('R')">
            <INPUT type=button name=btnKeyT value="T" onclick="fType('T')">
            <INPUT type=button name=btnKeyY value="Y" onclick="fType('Y')">
            <!--etc.-->
          </P>
        </FORM>
        </BODY>
        </HTML>
        this worked when i tested it. any good?

        EDIT: 14/07/02 11:19 AM BST: inserted single quotes into script
        Last edited by neil.c; Jul 14, 2002, 06:20 AM.
        neil.c

        Comment


        • #5
          I am getting an undefined error

          I am getting an undefined error for each letter
          such as Error: "T" is undefined??
          If you don't do it this year, you will be one year older when you do. "Warren Miller"

          Comment


          • #6
            Did you include singlequote marks?
            If u dont it thinks u've set T as a variable, and goes hunting for it.

            EG:
            ftype('T')
            _______________

            Will code for food
            _______________

            Comment


            • #7
              Yes, that is it. Thank you very very much

              I am going to need a backspace and a tab button to change fields.
              If you don't do it this year, you will be one year older when you do. "Warren Miller"

              Comment


              • #8
                function backspace() {
                document.theForm.theTextBox.value = document.theForm.theTextBox.value.slice(0, document.theForm.theTextBox.value.length -2);
                }

                tab.where = 0;
                function tab(posinega) {
                document.theForm.elements[tab.where + posinega].focus();
                }

                tab is written the way it is, so that you can make it tab forwards or backwards.

                tab(1); // tabs to the next space;
                tab(-1); // tabs backwards;

                keep in mind that if the person has a mouse, they really don't need the tab.

                also, the backspace function is sad, and there's nothing that can be done about it, because there's no good cross browser way to find out where the cursor is in a string. also, that means that ability to insert text, copy or cut text, etc, will all also be either really really hard to write, or simply impossible. i'm not sure which.
                bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

                i am a loser geek, crazy with an evil streak,
                yes i do believe there is a violent thing inside of me.

                Comment


                • #9
                  Touch Screen

                  I am messing around with a touch screen. I will just create a reset button because I am only asking for name and e-mail.
                  If you don't do it this year, you will be one year older when you do. "Warren Miller"

                  Comment


                  • #10
                    Tab

                    I need the tab to tab to the next input box. It does it, but it still forces everthing into the first input txtField1
                    If you don't do it this year, you will be one year older when you do. "Warren Miller"

                    Comment


                    • #11
                      how do you mean?
                      bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

                      i am a loser geek, crazy with an evil streak,
                      yes i do believe there is a violent thing inside of me.

                      Comment


                      • #12
                        At this link is where it is at. I cannot get the tab to work properly


                        <HTML>
                        <HEAD>
                        <TITLE>typing thing</TITLE>
                        <SCRIPT language=javascript>
                        <!--
                        var vCurrent = 1
                        function fType(keyPressed){ //adds the value of the pressed button to the field.
                        eval("document.frmStuff.txtField" + vCurrent + ".value += keyPressed")
                        }

                        function backspace() {
                        document.frmStuff.theTextBox.value = document.frmStuff.theTextBox.value.slice(0, document.frmStuff.theTextBox.value.length -2);
                        }

                        tab.where = 0;
                        function tab(posinega) {
                        document.frmStuff.elements[tab.where + posinega].focus();
                        }
                        //-->
                        </SCRIPT>
                        </HEAD>
                        <BODY>
                        <FORM name=frmStuff>
                        <P><INPUT type=text name=txtField1 size=50 onclick="vCurrent=1"></P>
                        <P><INPUT type=text name=txtField2 size=50 onclick="vCurrent=2"></P>
                        <P><INPUT type=text name=txtField3 size=50 onclick="vCurrent=3"></P>
                        <P>
                        <INPUT type=button name=btnKeyQ value="Q" onclick="fType('Q')">
                        <INPUT type=button name=btnKeyW value="W" onclick="fType('W')">
                        <INPUT type=button name=btnKeyE value="E" onclick="fType('E')">
                        <INPUT type=button name=btnKeyR value="R" onclick="fType('R')">
                        <INPUT type=button name=btnKeyT value="T" onclick="fType('T')">
                        <INPUT type=button name=btnKeyY value="Y" onclick="fType('Y')"><BR><BR>
                        <INPUT type=button name=btnKeyTab value="Tab" onclick="tab(1)">

                        <!--etc.-->
                        </P>
                        </FORM>
                        </BODY>
                        </HTML>
                        If you don't do it this year, you will be one year older when you do. "Warren Miller"

                        Comment


                        • #13
                          made a typo when i wrote the function. this should work:

                          tab.where = 0;
                          function tab(posinega) {
                          document.frmStuff.elements[tab.where += posinega].focus();
                          }
                          bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

                          i am a loser geek, crazy with an evil streak,
                          yes i do believe there is a violent thing inside of me.

                          Comment


                          • #14
                            Same thing
                            Could it be on this line

                            <INPUT type=button name=btnKeyTab value="Tab" onclick="tab(1)">???
                            If you don't do it this year, you will be one year older when you do. "Warren Miller"

                            Comment


                            • #15
                              wow, i'm out of it today or something.


                              try this:

                              tab.where = 0;
                              function tab(posinega) {
                              tab.where += posinega;
                              document.frmStuff.elements[tab.where].focus();
                              }
                              bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

                              i am a loser geek, crazy with an evil streak,
                              yes i do believe there is a violent thing inside of me.

                              Comment

                              Working...
                              X