Skip to content

Commit

Permalink
Merge pull request #1301 from capricorn86/1043-not-being-able-to-set-…
Browse files Browse the repository at this point in the history
…a-keycode-for-a-keyboardevent

fix: [#1043] Adds deprecated keyCode property to KeyboardEvent
  • Loading branch information
capricorn86 authored Mar 12, 2024
2 parents 08cd426 + 01ca3ca commit 4970c69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/happy-dom/src/event/events/IKeyboardEventInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ export default interface IKeyboardEventInit extends IUIEventInit {
metaKey?: boolean;
repeat?: boolean;
isComposing?: boolean;

/**
* @deprecated
*/
keyCode?: number;
}
6 changes: 6 additions & 0 deletions packages/happy-dom/src/event/events/KeyboardEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default class KeyboardEvent extends UIEvent {
public readonly repeat: boolean;
public readonly shiftKey: boolean;

/**
* @deprecated
*/
public readonly keyCode: number;

/**
* Constructor.
*
Expand All @@ -37,5 +42,6 @@ export default class KeyboardEvent extends UIEvent {
this.metaKey = eventInit?.metaKey ?? false;
this.repeat = eventInit?.repeat ?? false;
this.shiftKey = eventInit?.shiftKey ?? false;
this.keyCode = eventInit?.keyCode ?? 0;
}
}

0 comments on commit 4970c69

Please sign in to comment.