Mottie / Keyboard

Virtual Keyboard using jQuery ~
http://mottie.github.io/Keyboard/
Other
1.78k stars 723 forks source link

close keyboard is it open after certain time #612

Closed almih2m closed 6 years ago

almih2m commented 7 years ago

I try to close the keyboard if the user does not close the screen in a certain time is there any way to close it? by using code

also when I load screen on the old screen and the keyboard is open. the keyboard stay open on loaded screen .is there any way to solve that problem?

Thank you

Mottie commented 7 years ago

Hi @almih2m!

You can use a combination of Events and methods to close the keyboard if there is no activity after a certain amount of time.

In this example, the timer is set to 3 seconds

$(function() {
  var closeTimer,
    timeUntilClose = 3000; // 3 seconds

  function updateTimer(e, kb) {
    clearTimeout(closeTimer);
    closeTimer = setTimeout(function() {
      kb.close(kb.options.autoAccept);
    }, timeUntilClose);
  }

  $("#keyboard").keyboard({
    // keep any changes
    autoAccept: true,
    visible: updateTimer,
    change: updateTimer,
    beforeClose: updateTimer
  });
});

also when I load screen on the old screen and the keyboard is open. the keyboard stay open on loaded screen

I'm not really sure what you mean by that... is the keyboard set to be alwaysOpen? Then the above code won't work.

almih2m commented 7 years ago

I make timer to load page if user does not click on anything on screen

but when new page load over the old page and the keyboard was open, the keyboard not hide and freezes the screen

maybe the problem on .ui-keyboard-has-focus { z-index: 16001; }

???

almih2m commented 7 years ago

Another thing, I have visible as a function how I can call updateTimer function? visible: function () { .......... ........ .........

    },

Thank you a lot for your help

Mottie commented 7 years ago

but when new page load over the old page and the keyboard was open, the keyboard not hide and freezes the screen

I'm still not sure what you mean. Please share the code for the timer you're using. The css to increase the z-index is not the cause of this problem.

how I can call updateTimer function?

Follow this example:

$("#keyboard").keyboard({
  // keep any changes
  autoAccept: true,
  visible: function(e, kb) {
    // ...
    updateTimer(e, kb);
  },
  change: updateTimer,
  beforeClose: updateTimer
});
Mottie commented 6 years ago

I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue the discussion in this thread.