Capture "field +" keystroke from 10-key pad

243 Views Asked by At

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:

1

There are 1 best solutions below

2
On BEST ANSWER

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.