NG.I · Angular 22 practice question
A developer is building an input component and needs to capture specific details about a key press event within the template binding. If they use `(keyup)='handleKey($event)'`, what structure is guaranteed to be passed into the `handleKey` method?
<input type="text" (keyup)="handleKey($event)" />
Check answer and explanation
Correct answer: An object containing the raw DOM event data, allowing access to properties like event.key.
Explanation
The appropriate selection is 'An object containing the raw DOM event data, allowing access to properties like event.key' because the `$event` variable supplied to the handler holds a reference to the actual event object.
Common trap
The choice stating 'A simple boolean indicating if the key press was successful, as Angular abstracts the event details' is inaccurate because Angular does not simplify the event details into a mere success boolean. Furthermore, the selection 'A string representation of the input field's current value, replacing the need for a full event object' is incorrect because `$event` furnishes the event object, not the current input value directly.
Source: Angular docs: Adding event listeners — Accessing the event argument
Checked against the cited text on 2026-11-25.