Skip to main content

injectHeldKeys

还没翻译译自英文(tanstack.com)本页 8 段都还没译

function injectHeldKeys(): Signal<string[]>;

Defined in: injectHeldKeys.ts:23

Angular inject-based API that returns a signal of currently held keyboard keys.

Subscribes to the global KeyStateTracker and updates whenever keys are pressed or released.

Returns

Signal<string[]>

Signal of array of currently held key names

Example

@Component({
  template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
})
export class KeyDisplayComponent {
  heldKeys = injectHeldKeys()
}