I am doing a check on a keypress event (event.keyCode === $.ui.keyCode.TAB), and I am consistently getting -
$.ui.keyCode.TAB is null or not an object.
What could be causing that? am I missing a .js file somewhere?
If you do not need jquery UI, you could use the following enum instead:
if (event.keyCode == KeyCodes.Tab) {
// some code here
}
KeyCodes = {
BackSpace : 8 ,
Tab : 9 ,
Enter : 13 ,
Shift : 16 ,
Ctrl : 17 ,
Alt : 18 ,
PauseBreak : 19 ,
CapsLock : 20 ,
Esc : 27 ,
PageUp : 33 ,
PageDown : 34 ,
End : 35 ,
Home : 36 ,
ArrowLeft : 37 ,
ArrowUp : 38 ,
ArrowRight : 39 ,
ArrowDown : 40 ,
Insert : 45 ,
Delete : 46 ,
Digit0 : 48 ,
Digit1 : 49 ,
Digit2 : 50 ,
Digit3 : 51 ,
Digit4 : 52 ,
Digit5 : 53 ,
Digit6 : 54 ,
Digit7 : 55 ,
Digit8 : 56 ,
Digit9 : 57 ,
A : 65 ,
B : 66 ,
C : 67 ,
D : 68 ,
E : 69 ,
F : 70 ,
G : 71 ,
H : 72 ,
I : 73 ,
J : 74 ,
K : 75 ,
L : 76 ,
M : 77 ,
N : 78 ,
O : 79 ,
P : 80 ,
Q : 81 ,
R : 82 ,
S : 83 ,
T : 84 ,
U : 85 ,
V : 86 ,
W : 87 ,
X : 88 ,
Y : 89 ,
Z : 90 ,
WindowLeft : 91 ,
WindowRight : 92 ,
SelectKey : 93 ,
Numpad0 : 96 ,
Numpad1 : 97 ,
Numpad2 : 98 ,
Numpad3 : 99 ,
Numpad4 : 100,
Numpad5 : 101,
Numpad6 : 102,
Numpad7 : 103,
Numpad8 : 104,
Numpad9 : 105,
Multiply : 106,
Add : 107,
Subtract : 109,
DecimalPoint : 110,
Divide : 111,
F1 : 112,
F2 : 113,
F3 : 114,
F4 : 115,
F5 : 116,
F6 : 117,
F7 : 118,
F8 : 119,
F9 : 120,
F10 : 121,
F11 : 122,
F12 : 123,
NumLock : 144,
ScrollLock : 145,
SemiColon : 186,
Equal : 187,
Comma : 188,
Dash : 189,
Period : 190,
ForwardSlash : 191,
GraveAccent : 192,
BracketOpen : 219,
BackSlash : 220,
BracketClose : 221,
SingleQuote : 222
};
$.ui.keyCode.TAB comes with jquery UI. Make sure you've include the .js for jQuery and jQuery UI.
If that still fails, try jQuery.ui.keyCode.TAB or simply 9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With