JavaScript Event Listeners inside methods : <p>I was hoping to be able to call object methods from an event listener, however, I am unable to access object properties on the called function:</p>

<pre><code>import {action} from '../desktopIntegration/actions.js'

class Object {
  constructor() {
    this.property = 2
  }

  addListener() {
     action.on("keyup", this.printEvent)
  }

  printEvent() {
    console.log(this.property)
  }

}
</code></pre>

<p>This code gives the error:</p>

<pre><code> unable to access property of undefined
</code></pre>

<p>when addListener is called.</p>

<p>Is there a way to make this work? I want to keep the callback as a method function so that I can delete the listener on each instance of Object. </p>

<p>Thanks!</p>
