1

I'm migrating a legacy application from an AS400 to the web. All of the core users of the legacy app use the "field+" key on a 10-key pad to tab between fields. So, I need to capture that keystroke under the web application as well and use it in place of the tab key.

However, I've been unable to dig up any information explaining how one might capture that keystroke. I'm not at all opposed to using Javascript to do this, but I don't know what key to listen for.

I did find this

http://intermec.custhelp.com/app/answers/detail/a_id/10736/~/what-are-the-virtual-key-codes-for-field-plus-and-field-minus-for-as%2F400

...which seems to provide a "virtual key code", but I'm unsure how to use that in practice:

user2314737
  • 27,088
  • 20
  • 102
  • 114
T.J. Mahaffey
  • 65
  • 1
  • 8

1 Answers1

0

I created a Jsfiddle that allows you to see which keycodes are detected at keypress http://jsfiddle.net/user2314737/543zksjc/3/show/

(you'll need Javascript and JQuery)

$(".inputTxt").bind("keypress keyup keydown", function (event) {
    var evtType = event.type;
    var eWhich = event.which;
    var echarCode = event.charCode;
    var ekeyCode = event.keyCode;

    switch (evtType) {
        case 'keypress':
            $("#log").html($("#log").html() + "<b>" + evtType + "</b>" + " keycode: " + ekeyCode + " charcode: " + echarCode + " which: " + eWhich + "<br>");
            break;
        case 'keyup':
            $("#log").html($("#log").html() + "<b>" + evtType + "</b>" + " keycode: " + ekeyCode + " charcode: " + echarCode + " which: " + eWhich + "<p>");
            break;
        case 'keydown':
            $("#log").html($("#log").html() + "<b>" + evtType + "</b>" + " keycode: " + ekeyCode + " charcode: " + echarCode + " which: " + eWhich + "<br>");
            break;
        default:
            break;
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input class="inputTxt" type="text" />
<div id="log"></div>

Maybe this will help.

user2314737
  • 27,088
  • 20
  • 102
  • 114
  • Thank you! I didn't intend for anyone to write anything for me, but your efforts are appreciated. I'll use a version of this to capture the key codes and char codes for the "Field +" keys. Once I have those, I can bind all input fields on my form to something like this and invoke a tab stroke when the field+ key is pressed. – T.J. Mahaffey Jun 18 '15 at 19:56
  • Np I didn't write anything I recycled an old Jsfiddle that I had used for another answer on Stackoverflow ([javascript-listener-keypress-doesnt-detect-backspace](http://stackoverflow.com/a/30108293/2314737). Watch out with these keypress/keyup/keydown events because they're not handled by all browsers in the same way. – user2314737 Jun 19 '15 at 07:20