Document Object Model And Event Handling - Study Mode
[#1] When are the keyboard events fired?
Correct Answer
(B) When user clicks a key
Explanation
Solution: The keydown and keyup events are fired when the user presses or releases a key on the keyboard. They are generated for modifier keys, function keys, and alphanumeric keys.
[#2] How does a user generate multiple keydown events?
Correct Answer
(C) Pressing the key longer than usual
Explanation
Solution: If the user holds the key down long enough for it to begin repeating, there will be multiple keydown events before the keyup event arrives.
[#3] Which property is used to specify the key type when pressed?
Correct Answer
(A) keyCode
Explanation
Solution: The event object associated with these events has a numeric keyCode property that specifies which key was pressed.
[#4] What value does the keyCode property holds when a Shift key is pressed for adding punctuation character?
Correct Answer
(D) Digits
Explanation
Solution: The number keys always generate keyCode values for the digit that appears on the key, even if you are holding down Shift in order to type a punctuation character.
[#5] Which of the following are not key event properties?
Correct Answer
(A) Code key
Explanation
Solution: altKey, ctrlKeY, shiftKey, and metaKey are key event object’s properties, which are set to true if the corresponding modifier key is held down when the event occurs.