MCPcopy
hub / github.com/angular/components / _isSeparatorKey

Method _isSeparatorKey

src/material/chips/chip-input.ts:243–270  ·  view source on GitHub ↗

Checks whether a keycode is one of the configured separators.

(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

241
242 /** Checks whether a keycode is one of the configured separators. */
243 private _isSeparatorKey(event: KeyboardEvent): boolean {
244 if (!this.separatorKeyCodes) {
245 return false;
246 }
247
248 for (const key of this.separatorKeyCodes) {
249 let keyCode: number;
250 let modifiers: readonly ModifierKey[] | null;
251
252 if (typeof key === 'number') {
253 keyCode = key;
254 modifiers = null;
255 } else {
256 keyCode = key.keyCode;
257 modifiers = key.modifiers;
258 }
259
260 const modifiersMatch = !modifiers?.length
261 ? !hasModifierKey(event)
262 : hasModifierKey(event, ...modifiers);
263
264 if (keyCode === event.keyCode && modifiersMatch) {
265 return true;
266 }
267 }
268
269 return false;
270 }
271
272 /** Gets the value to set on the `readonly` attribute. */
273 protected _getReadonlyAttribute(): string | null {

Callers 1

_emitChipEndMethod · 0.95

Calls 1

hasModifierKeyFunction · 0.90

Tested by

no test coverage detected