[SOLVED] Flashlight turns off with x and turns on with x

How do I make a flashlight is off and turn on with the letter X and turn off with the same?

Hi @Ricardo_Reyes,

Listen for keyboard input and as soon as the key is released change the enabled property of your flashlight entity:

// when X is released toggle the entity state
this.entity.enabled = !this.entity.enabled;

This tutorial is a good starting point for handling keyboard input:


1 Like