# Remove Window Even Listener When display:none

**URL:** <https://forum.inductiveautomation.com/t/remove-window-even-listener-when-display-none/68984>\
**Category:** Module Development\
**Created:** [January 24, 2023, 11:36pm UTC](https://forum.inductiveautomation.com/t/remove-window-even-listener-when-display-none/68984 "2023-01-24T23:36:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [January 24, 2023, 11:36pm UTC](https://forum.inductiveautomation.com/t/remove-window-even-listener-when-display-none/68984/1 "2023-01-24T23:36:13Z")

</div>

My component has successfully added a event listener to the window, and it works beautifully, but now if the display property gets set to false the listener remains on the window. I have

```auto
componentWillUnmount() {
  window.removeEventListener("keydown", this.handleKeyDown);
}

```

but I am guessing the component does not unmount when the props.display is set to false. How would I go about removing or maybe stopping my listener when the display prop is set to false? Maybe I can some how bind the display prop to the component props so that I will know inside the handleKeyDown if the component is being displayed.
