Custom Events

Learn more about custom events and their properties in this lesson.

Events help us communicate with different entities by sending signals that other pieces of code can pick up and respond to. There can be requirements for which we need to achieve a customized behavior against a specific type of event. To accomplish this, A-frame offers custom events.

Emitting events

Using the emit(eventName, eventDetail, bubbles) function, we can emit from any entity element. For example, we can use the emit() function to define a changescale named event and pass target scale values to the event listener using the eventDetail argument:

Get hands-on with 1200+ tech skills courses.