Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard open callback (/toggle) #99

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/kioskboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
keysEnterText: 'Enter',
keysEnterCallback: undefined,
keysEnterCanClose: true,
keyboardOpenCallback: undefined,
};
var kioskBoardCachedKeys;
var kioskBoardNewOptions;
Expand Down Expand Up @@ -358,6 +359,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;
Expand Down