Virtual keyboard in any text fields

You have to change:

 if (event.target == modal_keyboard)

to:

 if (event.target == modal_keyboard_archive)

Also look at my latest code ( https://flows.nodered.org/flow/7fb5bc5ae66e6bc1b1c1b8e800bdef51 ), you'll need to add: input.change() after a key and backspace event

        type: function (key) {
            var input = this.settings.input,
                val = input.val(),
                input_node = input.get(0),
                start = input_node.selectionStart,
                end = input_node.selectionEnd;

            var max_length = $(input).attr("maxlength");
            if (start == end && end == val.length) {
                if (!max_length || val.length < max_length) {
                    input.val(val + key);
                    input.change()
                }
            } else {
                var new_string = this.insertToString(start, end, val, key);
                input.val(new_string);
                start++;
                end = start;
                input_node.setSelectionRange(start, end);
            }

            input.trigger('focus');

            if (shift && !capslock) {
                this.toggleShiftOff();
            }
        },

        backspace: function () {
            var input = this.settings.input,
                val = input.val();

            input.val(val.substr(0, val.length - 1));
            input.change()
        },
1 Like

you are absolutely right. Thanks for help.

Del button always return to the first lineand doesn't delete the letter where the trigger exists.

backspace: function () {
var input = this.settings.input,
val = input.val();

    input.val(val.substr(0, val.length - 1));
    input.change();
      input.trigger('focus');

},

i i add input.trigger('focus'); to avoide returning to the first line when deleting.
how about when the trigger exist in the middle ?

Good catch! I'll look into it!

Here's the new backspace function:

backspace: function () {
            var input = this.settings.input,
                val = input.val();
                input_node = input.get(0),
                start = input_node.selectionStart,
                end = input_node.selectionEnd;
            
            input.val(val.slice(0, start-1) + val.slice(start))
            input.change()
            input.focus()
            input_node.setSelectionRange(start-1, start-1);
        }
1 Like