Add KEYBOARD SHORTCUTS to Your Website with JavaScript

preview_player
Показать описание
In today's video I'll show you how easy it is to add keyboard shortcuts to your existing website, app or JavaScript game. This is achieved using the Keyboard Event Object, and Add Event Listener.

For your reference, check this out:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

#dcode #javascript
Рекомендации по теме
Комментарии
Автор

IMPORTANT:

Please make sure you put preventDefault *inside* your IF statements, to ensure you don't disable ALL default behaviour.

dcode-software
Автор

by the way if you havent already make sure that you do put the <script> elment as this is javascript and wont load in html until and unless you start the code with <script> and end with </script>

ArmaanM
Автор

You put preventDefault outside of the if statement, so the way you wrote that code would prevent all defaults, which would completely disable the keyboard from doing anything other than the alert in the if statement

jakeycakester
Автор

Very straightforward and clear. Thanks

mohamedelfodilihaddaden
Автор

What i like on the videos you make, they are straight forward and short but sweet which exactly the best way to get information

cmtg
Автор

your videos on coding are the most helpful, ngl

Leyero_editor
Автор

fine job, pal. works like the proverbial charm. thx!

maxkingman
Автор

Thank you, very accessible explanation, although I am not a native English speaker, but I understood everything

shamrai
Автор

Not related to the subject in the video, but sometimes I forget you're not Danny Ric! You're voice sounds just like his. Oh and I must thank you for all this videos, you have no idea how much it helps bro. Saves my ass on daily basis!

failscript
Автор

Its important to add: <<<... && !== document.activeElement >>> To prevent the shortcut from being executed while typing

boxs
Автор

When we type in Win+K, it opens up some windows settings window in the background. even when the prevent event was called. Is there anything else we should be writing to achieve it?

haroldbright
Автор

Everytime i press a key the code runs 2 times and 2nd time it runs 4 times and then 8 and 16 and so on... this eventually crashes my app. my code is exactly same as yours

prathamrajgor
Автор

How do I make it so that it will click a button on my website?

oeny
Автор

I like you just because you dont have a really accent

bhasim
Автор

Warning preventDefault(); = Disable all Inputs also.

ejierocks
Автор

Make a Video to prevent global Keyboard Events and override them with your own custom keyboard event shorcut registry.

jitenanand
Автор

if you would put your code in the description = 10/10 video

bhasim
Автор

Can you please, pleeease just use dark mode in Chrome... :(

BenjaminAster
join shbcf.ru