Skip to content

Loading…

How to recognize the key being pressed? #127

Closed
callmesusheel opened this Issue · 2 comments

2 participants

@callmesusheel

I want to run custom piece of code on click of each button. I can use the "change" callback provided. However I'm confused as to how to parse the input object that it returns. I need the value of the button clicked.

Please help me with this.

@Mottie
Owner

In version 1.16, I added a lastKey value to the API.

You can access it at any time as follows:

api  = $('#keyboard').data('keyboard');
key = api.lastKey;

or access it within a callback

$('#keyboard').bind('change.keyboard', function(e, api){
    if (api) {
        key = api.lastKey;
        // do something with the key
    }
});

if the virtual keyboard was used to enter the key, then api.$lastKey will contain the jQuery object of the button that was clicked.

@Mottie
Owner

I'm guessing this issue/question has been resolved, so I'm closing it. Please feel free to leave additional comments if you continue to have problems.

@Mottie Mottie closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.