本页还没有译文
本页 12 段还没译成Español,下面显示的是英文原文。injectKeyHold
还没翻译译自英文(tanstack.com)本页 12 段都还没译
function injectKeyHold(key): Signal<boolean>;Defined in: injectKeyHold.ts:40
Angular inject-based API that returns a signal that is true when the given key is held.
Subscribes to the global KeyStateTracker and uses a computed to determine if the specified key is held.
Parameters
key
IndividualKey | (() => IndividualKey)
The key to check (e.g. 'Shift', 'Control', 'Space') - can be a getter function
Returns
Signal<boolean>
Signal that returns true if the key is currently held down
Examples
@Component({
template: `{{ isShiftHeld() ? 'Shift is pressed!' : 'Press Shift' }}`,
})
export class ShiftIndicatorComponent {
isShiftHeld = injectKeyHold('Shift')
}@Component({
template: `
<span [style.opacity]="ctrl() ? 1 : 0.3">Ctrl</span>
<span [style.opacity]="shift() ? 1 : 0.3">Shift</span>
`,
})
export class ModifierIndicatorsComponent {
ctrl = injectKeyHold('Control')
shift = injectKeyHold('Shift')
}AI 翻译查看英文原文