I'm new to JavaScript and programming in general, and I have some questions about objects and events.
Say I have an object:
var computer = {
keyboard: {}
}
What I'm looking for is a way to register events to the keyboard object:
computer.keyboard.registerEvent( "keyEscape" );
Fire the event:
computer.keyboard.dispatchEvent( "keyEscape" );
And create event handlers:
computer.keyboard.addEventListener( "keyEscape", function() {...} );
I know how to do this with DOM elements but not objects. Is this something that can be done in JavaScript (maybe with the help of JQuery)?
Even the slightest bit of guidance would be appreciated greatly.