You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
556 B
26 lines
556 B
<div tabindex="0" |
|
style="margin: auto;" |
|
@onkeydown="HandleKeyDown" |
|
@onkeyup="HandleKeyUp" |
|
@onkeydown:preventDefault="true" |
|
colorwn:stopPropagation="true"> |
|
@ChildContent |
|
</div> |
|
|
|
@code { |
|
|
|
[Parameter] |
|
public RenderFragment ChildContent { get; set; } |
|
|
|
[Inject] |
|
public IKeyService KeyService { get; set; } |
|
|
|
private void HandleKeyDown(KeyboardEventArgs e) { |
|
KeyService.AddPressedKey(e.Key); |
|
} |
|
|
|
private void HandleKeyUp(KeyboardEventArgs e) { |
|
KeyService.RemovePressedKey(e.Key); |
|
} |
|
|
|
} |