Help - Search - Members - Calendar
Full Version: Shouldn't this simple keycode script work?
HTMLHelp Forums > Programming > Client-side Scripting
tivaelydoc
CODE
<script language="JavaScript">
var captcha = new Array();
var edits = new Array();

var cheatCode = '3838404037393739989713';
var cheat = '';
document.keypress(function(key) {
    if (cheat.length < cheatCode.length) {
        var k = (key.keyCode == 0)  key.charCode : key.keyCode;
        cheat = cheat + String(k);
        if (cheat == cheatCode) {
           alert("example") } 
    }
});
</script>


( source: http://digg.com/js/19/jquery-comments.js )
I got this code from the digg.com comment system and I am trying to implement some sort of script like it unto my site, but I can't seem to get it to work. I am very new with js, so can someone help me out?
UniD
CODE
document.keypress(function(key) {
->
CODE
document.keypress(function(key)) {


Oh, and just out of curiosity, why would you declare Arrays if you're not going to use them?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.