I saw these functions in some projects. For example: in Dagon (https://gecko0307.github.io/dagon/) there are functions like onKeyDown. This function doesn't need to call - it checks pressed keys every time. Or Update in Unity (game engine). It doesn't need to call, but it executes itself every frame.

Okay, maybe it sounds confusing. I just want to understand how to implement functions that wait for events and execute code inside the function. Something like this:

void onKeyPressed(int key) {
    //the code to be executed if a key has been pressed
}


Reply via email to