With this table you can catch key presses using Javascript with the following:
//The javascript functions:
function InKeyRange(e, min, max)
{
if (min == null)
min = 0;
if (max == null)
max = 65000;
if (max < min)
{
var tmp = min;
min = max;
max = tmp;
}
var keyCode = (is_nav) ? e.which : e.keyCode;
return ((min <= keyCode) && (keyCode <= max));
}
// test if the keycode of the key pressed is a numeric key 0-9
function IsNumericKey(e)
{
return InKeyRange(e, 48, 57);
}
//Call javascript functions from within a textbox
<asp:TextBox Runat="server" onkeypress="return IsNumericKey(event);" Width="35" ID="TB1"></asp:TextBox>
If the key pressed is not within the givin value, the textbox won't accept the input.
Now here is the table defining the keyCodes:
a = 97 b = 98 c = 99 d = 100 e = 101 f = 102 g = 103 h = 104 i = 105 j = 106 | k = 107 l = 108 m = 109 n = 110 o = 111 p = 112 q = 113 r = 114 s = 115 t = 116 | u = 117 v = 118 w = 119 x = 120 y = 121 z = 122 0 = 48 1 = 49 2 = 50 3 = 51 | 4 = 52 5 = 53 6 = 54 7 = 55 8 = 56 9 = 57 ' = 39 , = 44 - = 45 . = 46 | / = 47 : = 58 = = 61 [ = 91 \ = 92 ] = 93 ` = 96 return = 13 escape = 27 space bar = 32 |