Use key instead of keycode for key event (#16625)

This commit is contained in:
Paul Bottein 2023-05-25 18:47:57 +02:00 committed by GitHub
parent c4ff1a8646
commit 71bb540352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 15 additions and 15 deletions

View File

@ -190,7 +190,7 @@ export class HcConnect extends LitElement {
private _handleInputKeyDown(ev: KeyboardEvent) { private _handleInputKeyDown(ev: KeyboardEvent) {
// Handle pressing enter. // Handle pressing enter.
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._handleConnect(); this._handleConnect();
} }
} }

View File

@ -218,7 +218,7 @@ class HassioRepositoriesDialog extends LitElement {
private _handleKeyAdd(ev: KeyboardEvent) { private _handleKeyAdd(ev: KeyboardEvent) {
ev.stopPropagation(); ev.stopPropagation();
if (ev.keyCode !== 13) { if (ev.key !== "Enter") {
return; return;
} }
this._addRepository(); this._addRepository();

View File

@ -105,7 +105,7 @@ export class HaAuthFlow extends LitElement {
} }
this.addEventListener("keypress", (ev) => { this.addEventListener("keypress", (ev) => {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._handleSubmit(ev); this._handleSubmit(ev);
} }
}); });

View File

@ -54,7 +54,7 @@ export class HaTab extends LitElement {
}); });
private _handleKeyDown(ev: KeyboardEvent): void { private _handleKeyDown(ev: KeyboardEvent): void {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
(ev.target as HTMLElement).click(); (ev.target as HTMLElement).click();
} }
} }

View File

@ -93,7 +93,7 @@ class StepFlowForm extends LitElement {
} }
private _handleKeyDown = (ev: KeyboardEvent) => { private _handleKeyDown = (ev: KeyboardEvent) => {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._submitStep(); this._submitStep();
} }
}; };

View File

@ -324,7 +324,7 @@ export class HaVoiceCommandDialog extends LitElement {
private _handleKeyUp(ev: KeyboardEvent) { private _handleKeyUp(ev: KeyboardEvent) {
const input = ev.target as HaTextField; const input = ev.target as HaTextField;
if (ev.keyCode === 13 && input.value) { if (ev.key === "Enter" && input.value) {
this._processText(input.value); this._processText(input.value);
input.value = ""; input.value = "";
this._showSendButton = false; this._showSendButton = false;

View File

@ -50,7 +50,7 @@ class OnboardingAnalytics extends LitElement {
protected firstUpdated(changedProps) { protected firstUpdated(changedProps) {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
this.addEventListener("keypress", (ev) => { this.addEventListener("keypress", (ev) => {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._save(ev); this._save(ev);
} }
}); });

View File

@ -282,7 +282,7 @@ class OnboardingCoreConfig extends LitElement {
100 100
); );
this.addEventListener("keypress", (ev) => { this.addEventListener("keypress", (ev) => {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._save(ev); this._save(ev);
} }
}); });

View File

@ -94,7 +94,7 @@ class OnboardingCreateUser extends LitElement {
setTimeout(() => this._form?.focus(), 100); setTimeout(() => this._form?.focus(), 100);
this.addEventListener("keypress", (ev) => { this.addEventListener("keypress", (ev) => {
if ( if (
ev.keyCode === 13 && ev.key === "Enter" &&
this._newUser.name && this._newUser.name &&
this._newUser.username && this._newUser.username &&
this._newUser.password && this._newUser.password &&

View File

@ -235,7 +235,7 @@ class DialogThingtalk extends LitElement {
}; };
private _handleKeyUp(ev: KeyboardEvent) { private _handleKeyUp(ev: KeyboardEvent) {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._generate(); this._generate();
} }
} }

View File

@ -130,7 +130,7 @@ class HaInputSelectForm extends LitElement {
private _handleKeyAdd(ev: KeyboardEvent) { private _handleKeyAdd(ev: KeyboardEvent) {
ev.stopPropagation(); ev.stopPropagation();
if (ev.keyCode !== 13) { if (ev.key !== "Enter") {
return; return;
} }
this._addOption(); this._addOption();

View File

@ -73,7 +73,7 @@ export class DialogAddUser extends LitElement {
protected firstUpdated(changedProperties: PropertyValues) { protected firstUpdated(changedProperties: PropertyValues) {
super.firstUpdated(changedProperties); super.firstUpdated(changedProperties);
this.addEventListener("keypress", (ev) => { this.addEventListener("keypress", (ev) => {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._createUser(ev); this._createUser(ev);
} }
}); });

View File

@ -296,7 +296,7 @@ export class AssistPipelineRunDebug extends LitElement {
} }
private _handleContinueKeyDown(ev) { private _handleContinueKeyDown(ev) {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._runTextPipeline(); this._runTextPipeline();
} }
} }

View File

@ -301,7 +301,7 @@ class HuiShoppingListCard
} }
private _addKeyPress(ev): void { private _addKeyPress(ev): void {
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._addItem(null); this._addItem(null);
} }
} }

View File

@ -118,7 +118,7 @@ class HaChangePasswordCard extends LitElement {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
this.addEventListener("keypress", (ev) => { this.addEventListener("keypress", (ev) => {
this._statusMsg = undefined; this._statusMsg = undefined;
if (ev.keyCode === 13) { if (ev.key === "Enter") {
this._changePassword(); this._changePassword();
} }
}); });