İngilizce

Keyboard Events
JavaScript can monitor the keyboard through keyboard events.
Each time a user presses a key on the keyboard, they generate
a keyboard event, which is a lot like the mouse events we saw
in Chapter 00. With mouse events, we used jQuery to determine
where the cursor was when the event took place. With keyboard
events, you can use jQuery to determine which key was pressed
and then use that information in your code. For example, in this
chapter we’ll make a ball move left, right, up, or down when the
user presses the left, right, up, or down arrow key.
We’ll use the keydown event, which is triggered whenever a
user presses a key, and we’ll use jQuery to add an event handler
to the keydown event. That way, every time a keydown event occurs,
our event handler function can find out which key was pressed
and respond accordingly.

Türkçe

Klavye Olayları
JavaScript, klavye olayları aracılığıyla klavyeyi izleyebilir.
Kullanıcı klavyede bir tuşa her bastığında, 00. Bölümde gördüğümüz fare olaylarına çok benzeyen bir klavye olayı oluşturur.
Fare olaylarında, olayın gerçekleştiği sırada imlecin nerede olduğunu belirlemek için jQuery kullandık.
Klavye olaylarında ise, hangi tuşa basıldığını belirlemek için jQuery kullanabilir ve ardından bu bilgiyi kodunuzda kullanabilirsiniz.
Örneğin, bu bölümde, kullanıcı sol, sağ, yukarı veya aşağı ok tuşuna bastığında bir topun sola, sağa, yukarı veya aşağı hareket etmesini sağlayacağız.
Kullanıcı bir tuşa bastığında tetiklenen keydown olayını kullanacağız ve keydown olayına bir olay işleyici eklemek için jQuery kullanacağız. Bu sayede, her tuşa basma olayı gerçekleştiğinde, olay işleyici fonksiyonumuz hangi tuşa basıldığını bulabilir ve buna göre yanıt verebilir.

(5000 karakter kaldı)
İngilizce
Türkçe

İçindekiler

Son çeviriler

devamını göster›
ADS - REKLAMLAR