Click here to Skip to main content
14,981,532 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Hope you are all well, I've got a question with regards to a digital board I'm creating to show targets and yields on a touchscreen . I have a page ready with conditional formatting that works ok problem is I've tried to add a virtual keyboard when you click the text box the keyboard appears and you get to type targets etc. The issue is when using the virtual keyboard the addEventListener doesn't seem to acknowledge the change in the text box , which is does with a physical keyboard . Has anyone else has had an issue with adding a virtual keyboard to a text box with conditional formatting...example being if the target box is less than the actual box then the actual box will be green.

A simple version is shown below..without the virual keyboard code

Thanks for reading


What I have tried:

<pre><!DOCTYPE html>
<input type="text" id="text1" size="50">
<input type="text" id="text2" size="50">   
    <script type="text/javascript">
        document.getElementById("text1").addEventListener("keyup", testpassword2);
        document.getElementById("text2").addEventListener("keyup", testpassword2);

function testpassword2() {
  var text1 = document.getElementById("text1");
  var text2 = document.getElementById("text2");
  if (text1.value <= text2.value) = "#2EFE2E";
  else = "red";
Updated 13-Oct-20 21:17pm

In my experience, a "virtual keyboard" has "buttons" (or something similar), and you wire up the buttons, not "keyboard" events (since now there is no KB).

You need to use the equivalent of a "send keys" if you want to tap into "keyboard input" events (without an actual KB).

Depending on the scenario, the VKB may have little to do other than backspace and accept numbers; so handling the events doesn't have to be a big deal.

(And since when are "passwords" compared using "less than or equal to"?).
Thanks for the reply gerry, i had linked a virtual keyboard that I had found to the text box and thought that properties such as onchange/change for the addEventListener would detect a change in the text box as I assumed the keyup type events wouldn't work in this case. Ill have to try and find out how to emulate a keyboard event on the virtual keyboard i guess......why i have password in the function name i dont know...well spotted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900