- 1

How to add a keyboard listener to my WebPage using JS

I want to make a game that move a block on pressing keys Now I am using input tag of button type but I need keyboard listeners which are better option for this thing so help me please

12th Apr 2020, 8:51 AM
Abhay
Abhay - avatar
3 Answers
0
window.addEventListener('keyup', myFunction) So you can track the type of a key being pressed
12th Apr 2020, 11:48 AM
Nejat Mhango
Nejat Mhango - avatar
0
'keyup', 'keydown'
12th Apr 2020, 11:48 AM
Nejat Mhango
Nejat Mhango - avatar
- 1
Can u guys explain me wth an complete example plzzzzzz
12th Apr 2020, 12:34 PM
Abhay
Abhay - avatar