From 88a0747a51819107695e19f4968a465fb0589f01 Mon Sep 17 00:00:00 2001 From: Matteo Gheza Date: Fri, 11 Oct 2024 16:26:20 +0200 Subject: [PATCH 1/2] Add keyboard open callback (/toggle) --- index.d.ts | 6 ++++++ src/kioskboard.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/index.d.ts b/index.d.ts index 58183d2..85a3ad8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -166,6 +166,12 @@ declare namespace KioskBoard { * @defaultValue `true` */ keysEnterCanClose?: boolean; + + /** + * @property {function} - Optional, The callback function of the virtual keyboard. This function will be called when the input get focused. Return false to prevent keyboard open. + * @defaultValue `undefined` + */ + keyboardOpenCallback?: (input: HTMLInputElement | HTMLTextAreaElement) => boolean|void; } /** diff --git a/src/kioskboard.js b/src/kioskboard.js index a008a08..60f14e7 100644 --- a/src/kioskboard.js +++ b/src/kioskboard.js @@ -358,6 +358,10 @@ // each input focus listener: begin var inputFocusListener = function (e) { + if (typeof opt.keyboardOpenCallback === 'function' && !opt.keyboardOpenCallback(input)) { + return false; + } + // input element variables: begin var theInput = e.currentTarget; var theInputSelIndex = 0; From d978db62f1c3a06d997e6ed2c50dab82307d0cf9 Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 21 Oct 2024 19:04:31 +0200 Subject: [PATCH 2/2] Add keyboardOpenCallback to default options --- src/kioskboard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kioskboard.js b/src/kioskboard.js index 60f14e7..4da5037 100644 --- a/src/kioskboard.js +++ b/src/kioskboard.js @@ -68,6 +68,7 @@ keysEnterText: 'Enter', keysEnterCallback: undefined, keysEnterCanClose: true, + keyboardOpenCallback: undefined, }; var kioskBoardCachedKeys; var kioskBoardNewOptions;