Skip to content

Instantly share code, notes, and snippets.

@dethbiscuit
Created July 5, 2018 05:55
Show Gist options
  • Save dethbiscuit/976ca0a2e9ccf2150f06a58401f93e0c to your computer and use it in GitHub Desktop.
Save dethbiscuit/976ca0a2e9ccf2150f06a58401f93e0c to your computer and use it in GitHub Desktop.
[jQuery] Txtbox events
<input id="txtInput" type="text" />
<br/>
<span id="result"></span>
$(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