Embarking on my learning journey with JavaScript and programming in general, I find myself pondering over objects and events.
Imagine this object:
var computer = {
keyboard: {}
}
I'm keen on finding a method to attach events to the keyboard object:
computer.keyboard.registerEvent( "keyEscape" );
To trigger the event:
computer.keyboard.dispatchEvent( "keyEscape" );
And establish event handlers:
computer.keyboard.addEventListener( "keyEscape", function() {...} );
While I understand how to achieve this with DOM elements, working out a solution with objects poses a challenge. Is it feasible in JavaScript (possibly with JQuery)?
Any form of guidance, no matter how small, would be greatly appreciated.