Initial Commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
@using Services.Website
|
||||
@inject IKeyService KeyService
|
||||
|
||||
@inject IDataCollectionService DataCollectionService
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
|
||||
<div tabindex="0"
|
||||
style="margin: auto;"
|
||||
@onkeydown="HandleKeyDown"
|
||||
@onkeyup="HandleKeyUp"
|
||||
@onkeydown:preventDefault="true"
|
||||
@onkeydown:stopPropagation="true">
|
||||
@ChildContent
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment ChildContent { get; set; } = default!;
|
||||
|
||||
private void HandleKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
DataCollectionService.SendEvent(
|
||||
DataCollectionKeys.BuildCalcInput,
|
||||
new Dictionary<string, string> { { "key", e.Key.ToLower() }, { "input-source", "keyboard" } }
|
||||
);
|
||||
|
||||
KeyService.AddPressedKey(e.Key);
|
||||
}
|
||||
|
||||
private void HandleKeyUp(KeyboardEventArgs e)
|
||||
{
|
||||
KeyService.RemovePressedKey(e.Key);
|
||||
}
|
||||
|
||||
protected override bool ShouldRender()
|
||||
{
|
||||
#if DEBUG
|
||||
JsRuntime.InvokeVoidAsync("console.time", "InputPanelComponent");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
#if DEBUG
|
||||
JsRuntime.InvokeVoidAsync("console.timeEnd", "InputPanelComponent");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user