2

I have a standard textbox and I've got jQuery on the page. I want to act when the user types a space into the textbox. I am, however, unsure of how to do this.

Can anybody give me a hand with this please?

1 Answer 1

6
var KEYS = {
    SPACE: 32
};

$("#textbox").keyup(function(e) {
    if (e.keyCode === KEYS.SPACE) {
        console.log("Space key pressed");
    }
});

References:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.