Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var chars, pressed;
- pressed = false;
- chars = [];
- $(window).on('keypress', function(e) {
- if (e.which !== 13) {
- chars.push(String.fromCharCode(e.which));
- }
- if (pressed === false) {
- setTimeout(function() {
- var barcode;
- if (chars.length >= 5) {
- barcode = chars.join("");
- }
- chars = [];
- return pressed = false;
- }, 300);
- }
- return pressed = true;
- });
Add Comment
Please, Sign In to add comment