From 1147601610f6603842ecf53079114d6679af4298 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Tue, 31 Jan 2023 17:02:14 -0500 Subject: [PATCH] Add event to onKeyReleased per https://github.com/hodgef/react-simple-keyboard/issues/2231 --- src/lib/components/Keyboard.ts | 2 +- src/lib/interfaces.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Keyboard.ts b/src/lib/components/Keyboard.ts index 94142f5e..7a082e14 100644 --- a/src/lib/components/Keyboard.ts +++ b/src/lib/components/Keyboard.ts @@ -684,7 +684,7 @@ class SimpleKeyboard { * Calling onKeyReleased */ if (button && typeof this.options.onKeyReleased === "function") - this.options.onKeyReleased(button); + this.options.onKeyReleased(button, e); } /** diff --git a/src/lib/interfaces.ts b/src/lib/interfaces.ts index 4a8c4dd0..01fa3026 100644 --- a/src/lib/interfaces.ts +++ b/src/lib/interfaces.ts @@ -276,6 +276,16 @@ export interface KeyboardOptions { */ onChangeAll?: (inputObj: KeyboardInput, e?: MouseEvent) => any; + /** + * Retrieves the pressed key + */ + onKeyPress?: (button: string, e?: MouseEvent) => any; + + /** + * Retrieves the released key + */ + onKeyReleased?: (button: string, e?: MouseEvent) => any; + /** * Module options can have any format */