الرجوع الي الدرس
هذة المادة العلميه متاحه فقط باللغات الأتيه: English, Español, فارسی, Français, Indonesia, Italiano, 日本語, 한국어, Русский, Українська, 简体中文. من فضلك, ساعدنا قم بالترجمه إلى عربي.

Keyboard-driven mouse

الأهمية: 4

Focus on the mouse. Then use arrow keys to move it:

عرض توضيحي في نافذة جديدة

P.S. Don’t put event handlers anywhere except the #mouse element. P.P.S. Don’t modify HTML/CSS, the approach should be generic and work with any element.

افتح sandbox للمهمه.

We can use mouse.onclick to handle the click and make the mouse “moveable” with position:fixed, then mouse.onkeydown to handle arrow keys.

The only pitfall is that keydown only triggers on elements with focus. So we need to add tabindex to the element. As we’re forbidden to change HTML, we can use mouse.tabIndex property for that.

P.S. We also can replace mouse.onclick with mouse.onfocus.

افتح الحل في sandbox.