keys
A dictionary of special keys' ASCII codes, which can be accessed by user-friendly names, instead of their numeric values. The collection includes only key codes, which are used by the Kendo UI widgets' source code.
kendo.keys collection
js
kendo.keys = {
INSERT: 45,
DELETE: 46,
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
ESC: 27,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
END: 35,
HOME: 36,
SPACEBAR: 32,
PAGEUP: 33,
PAGEDOWN: 34,
F2: 113,
F10: 121,
F12: 123,
NUMPAD_PLUS: 107,
NUMPAD_MINUS: 109,
NUMPAD_DOT: 110
}
The key codes are especially helpful in keydown, keyup and keypress event handlers.
Example
<input type="text" id="textbox" />
<script>
$("#textbox").on("keydown", function(e) {
// Check for specific keys using kendo.keys
if (e.keyCode === kendo.keys.ENTER) {
console.log("Enter key pressed");
} else if (e.keyCode === kendo.keys.ESC) {
console.log("Escape key pressed");
$(this).val("");
} else if (e.keyCode === kendo.keys.TAB) {
console.log("Tab key pressed");
} else if (e.keyCode === kendo.keys.DELETE || e.keyCode === kendo.keys.BACKSPACE) {
console.log("Delete or Backspace key pressed");
}
});
</script>
kendo.keys usage example
js
function onMyKeyPress(e) {
// if ENTER key is pressed, do something
if (e.keyCode == kendo.keys.ENTER) {
// .....
}
}
In this article