How can I call a method from my current class using keypress ?

How can I call a method from my current class using keypress ?

Hello,

I have the following code in one of my pages. My problem is caused, because the method "processEvent" is never called, but I have no idea why. I guess it is broken, because I don't relay the "this" object correctly.

 Any ideas?

  1. <script type="text/javascript">

    var MyClass = function()
    {
        this.init = function()
        {
            $("mydiv").keypress( this.processEvent );
        }
        ////////////////////////////////////////////
       
        this.processEvent = function( event )
        {
            // Something here...
        }
        ////////////////////////////////////////////
    }
















  2. var mc = new MyClass();
  3. mc.init();

  4. </script>


Thanks in advance.