WordPress Plugin with Javascript

I am working on a wordpress plugin which allows a user to enter a image url and konami code. When the konami code is entered an image pops up, but I can’t get it to animate, I am somewhat unfamiliar with jQuery and Javascript, and I am just starting to learn it… Any help would be fantastic!

<script type="text/javascript" charset="utf-8">
if ( window.addEventListener ) {
  var kkeys = [], konami = "{$this->opts['wpk_code']['current']}";
  window.addEventListener("keydown", function(e){
    kkeys.push( e.keyCode );
    if ( kkeys.toString().indexOf( konami ) >= 0 ){
     var elms=document.getElementById("konami").style;
     elms.display=(elms.display=="block")?"none":"block";
}
  }, true);
}
</script>

Related posts

Leave a Reply

2 comments

  1. Try this:

    $('#inputField').keyup(function () {
                if ($(this).val().length > 0) {
                    $('#konami').animate({
                        opacity: 1,
                        left: '50'
                    }, 100); 
                }
                else {
                    $('#konami').animate({
                        opacity: 0,
                        left: '0'
                    }, 100); 
                }
            });
    

    HTML:

    <input type="text" id="inputField" />
    <img src="..." id="konami" style="position:relative;" />