1

I am making a simple text adventure using javascript and I need a way to make the player be able to write 1, 2, 3 or 4 when asked in order to select the corresponding choices. How do I do this? readline() and console.read() don't work.

I am not using a website. I need it in the console.

Euphe
  • 3,531
  • 6
  • 39
  • 69

1 Answers1

0
document.addEventListener('keydown', function(event) {
    if(event.keyCode == EVENTCODE) {
        //action
    }

});

in the place of EVENTCODE place numbers:

48 = 0
49 = 1 
50 = 2 
51 = 3 
52 = 4 
53 = 5 
54 = 6 
55 = 7 
56 = 8 
57 = 9,
mario
  • 477
  • 3
  • 16