# Programming Concept onEvent

**URL:** <https://forum.code.org/t/programming-concept-onevent/32300>\
**Category:** Coding and Debugging Help\
**Created:** [February 20, 2020, 6:01pm UTC](https://forum.code.org/t/programming-concept-onevent/32300 "2020-02-20T18:01:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)\
**Post date:** [February 20, 2020, 7:00pm UTC](https://forum.code.org/t/programming-concept-onevent/32300/2 "2020-02-20T19:00:01Z")

</div>

Hello Maya,

Here are two forum threads that have discussions about onEvents and how they work. Hope this helps.

> [@OnEvent within another onEvent allowed?](https://forum.code.org/t/onevent-within-another-onevent-allowed/15025/2):
>
> Oooh, this is a tricky misconception about how event handlers work. When you call onEvent() it creates a new event handler sitting in the background responding to events. Once you’ve created an event handler, there’s no way to get rid of it. When you restart the game the old event handlers are still hanging out in the background and new event handlers are created, which is why you see it changing by 2 instead of one. As a rule, you should never put an onEvent() block inside another block in ord…

> [@Functions and Event handlers](https://forum.code.org/t/functions-and-event-handlers/15418/2):
>
> Hey @kaitie_o_bryan, I obviously can’t speak to how I handle this in a classroom but I can at least tell you a little bit about why this is “wrong”. Incorrectly Using a Function Defined in Another Function: // Example of declaring a function inside another function function outer(){ console.log("outer"); function inner(){ console.log("inner"); } } outer(); // Will print the word "outer" to the console inner(); // Will lead to an error. Why? The example above will lead to an error…

---

_[View the full topic](https://forum.code.org/t/programming-concept-onevent/32300)._
