Created
July 5, 2018 05:55
-
-
Save dethbiscuit/976ca0a2e9ccf2150f06a58401f93e0c to your computer and use it in GitHub Desktop.
[jQuery] Txtbox events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input id="txtInput" type="text" /> | |
<br/> | |
<span id="result"></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$("#txtInput").keypress( | |
function(event) { | |
var value = ''; | |
if (event.which == 64) { | |
value = "You have pressed @ sign"; | |
} else if (event.which == 35) { | |
value = "You have pressed # sign"; | |
} else if (event.which == 36) { | |
value = "You have pressed $ sign"; | |
} else if (event.which == 42) { | |
value = "You have pressed * sign"; | |
} else if (event.which >= 65 && event.which <= 90) { | |
value = "You have pressed uppercase alphabet character"; | |
} else if (event.which >= 97 && event.which <= 122) { | |
value = "You have pressed lowercase alphabet character"; | |
} | |
$('#result').text(value); | |
}); | |
$("#txtInput").click(function logWhich(e) { | |
//Detect right click with body.click function | |
$('#result').text(btns[e.which] + '[' + e.which + ']'); | |
}); | |
var btns = ['', 'Left (1)', 'Middle (2)', 'Right (3)']; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment