Forum Url:
http://thebattlegrounds.smfforfree3.comA javascript key capturer, I made this so if someone presses a certain key in a non-textarea they will be direct to... BLAH BLAH BLAH
so here we go... Let me know if it works I used it for a website I created myself. but im unsure for the forums, I'd put this in the headers.
Asking for a preview? There is not.This is what the coding would look like...
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
function NNKeyCap(thisOne)
{
if (thisOne.modifiers & Event.SHIFT_MASK)
{
if (thisOne.which == 37)
{alert('That\'s the % key')};
if (thisOne.which == 90)
{alert('That\'s the Z key')};
if (thisOne.which == 41)
{alert('That\'s the ) key')};
}
if (thisOne.which == 61)
{alert('That\'s the = key')};
if (thisOne.which == 106)
{alert('That\'s the j key')};
if (thisOne.which == 51)
{alert('That\'s the 3 key')};
}
function IEKeyCap()
{
if (window.event.shiftKey)
{
if (window.event.keyCode == 37)
{alert('That\'s the % key')};
if (window.event.keyCode == 90)
{alert('That\'s the Z key')};
if (window.event.keyCode == 41)
{alert('That\'s the ) key')};
}
if (window.event.keyCode == 61)
{alert('That\'s the = key')};
if (window.event.keyCode == 106)
{alert('That\'s the j key')};
if (window.event.keyCode == 51)
{alert('That\'s the 3 key')};
}
if (navigator.appName == 'Netscape') {
window.captureEvents(Event.KEYPRESS);
window.onKeyPress = NNKeyCap;
}
//-->
// (C) Mr Css Copyright
</SCRIPT>
<BODY onKeyPress="IEKeyCap()">
alright... So now you wonder What the hell? right? yeap, I know I will walk you through on where to put everything..
NOTE: The script will also work no matter if the key stroke is lower or uppercase.
heres a place to set the key capturers...
if (window.event.keyCode == 61)
{alert('That\'s the = key')};
if (window.event.keyCode == 106)
{alert('That\'s the j key')};
if (window.event.keyCode == 51)
{alert('That\'s the 3 key')};
}
Alright so let me show you what you must do...
if (window.event.keyCode == 61) {alert('That\'s the = key')};
if (window.event.keyCode == 106) {alert('That\'s the j key')};
if (window.event.keyCode == 51) {alert('That\'s the 3 key')};
}
alright all the red places are very important i left some comments on what the key captures are set on. Edit the
if (window.event.keyCode == 51)Whats really important is inside this:
if (window.event.keyCode == 51) and that is...
keyCode == 51) Yes! the KEYCODE! and lets extract the code once more...
51the number is most important... You edit this number :
51 or whatever number that is set after
keyCode == .
And yes I should give you the key capturing numbers...
Here they are...
9 =
Tab 11 =
Home 13 =
Enter
32 =
Space Bar 33 = ! 34 = "
35 = # 36 = $ 37 = %
38 = & 39 = ' 40 = (
41 = ) 42 = * 43 = +
44 = , 45 = - 46 = .
47 = / 48 = 0 49 = 1
50 = 2 51 = 3 52 = 4
53 = 5 54 = 6 55 = 7
56 = 8 57 = 9 58 = :
59 = ; 60 = < 61 = =
62 = > 63 = ? 64 = @
65 = A 66 = B 67 = C
68 = D 69 = E 70 = F
71 = G 72 = H 73 = I
74 = J 75 = K 76 = L
77 = M 78 = N 79 = O
80 = P 81 = Q 82 = R
83 = S 84 = T 85 = U
86 = V 87 = W 88 = X
89 = Y 90 = Z 91 = [
92 = \ 93 = ] 94 = ^
95 = - 96 = ` 97 = a
98 = b 99 = c 100 = d
101 = e 102 = f 103 = g
104 = h 105 = i 106 = j
107 = k 108 = l 109 = m
110 = n 111 = o 112 = p
113 = q 114 = r 115 = s
116 = t 117 = u 118 = v
119 = w 120 = x 121 = y
122 = z 123 = { 124 = |
125 = } 126 = ~
the number is most important the icon is not to be copied into the code... just the number. If you have any problems let me know ! thank you!
Mr Css.