Mottie / Keyboard

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

Random keypress and JQuery Warning #593

Closed steven-work-space closed 7 years ago

steven-work-space commented 7 years ago

Hi !

Thanks a lot for your work.

I have a trouble... I'm using the virtualkeyboard in a AngularJs project on a Raspberry. The raspberry is connected to the official touchscreen 7". So the virtualkeyboard is the input of my application.

I'm using the lastest version => 1.26.26

But when i'm using it, i press for exemple "enter" or just the letter "a" and sometimes, an other letter get print. This char is completly random. If I press and hold for a long time the key "e" it will write "e" but also a sequence of random characters ("aesfjieyshe") ...

I have x3 warnings jQuery messages when i press a key: "ignored attempt to cancel a touchstart event with cancelable=false , for example because scrolling is in progress and cannot be interrupted"

Have you an idea ?

Thanks a lot

Mottie commented 7 years ago

Hi @LeReveur711!

I'm sorry to hear you're having trouble. Please let me know what version of jQuery you're using and please share the keyboard initialization code being used.

steven-work-space commented 7 years ago

Hi !

Thanks a lot for your response !

Here, the configuration:

// Virtual keyboard configuration
  .config(['VKI_CONFIG', function(VKI_CONFIG) {
    VKI_CONFIG.language = 'fr';
    VKI_CONFIG.layout = 'french-azerty-light';
    VKI_CONFIG.css = {
      buttonDefault: 'btn btn-lg btn-info',
      buttonHover: 'grey bold',
      buttonActive: 'grey bold',
    };
    VKI_CONFIG.usePreview = false;
    VKI_CONFIG.userClosed = false;
    VKI_CONFIG.autoAccept = true;
    VKI_CONFIG.repeatRate = 0;
    VKI_CONFIG.reposition = false;
    VKI_CONFIG.useCombos = false;
    VKI_CONFIG.extensions = {
      addTyping: false,
    };
    VKI_CONFIG.position = false; 
    // On show keyboard
    VKI_CONFIG.visible = function(e, kb) {
      // Set first char in uppercase
      /*if ($.keyboard.caret(kb.$preview).start === 0) {
       kb.showKeySet('shift');
       }*/
      // Add div to scroll at the bottom of content (else keyboard override it)
      $('.ui-keyboard').after('<div id="ui-keyboard-height"></div>');
      // Scroll to the input
      $(window).scrollTop(kb.$el.offset().top - 10);
    };
    VKI_CONFIG.hidden = function() {
      // Remove div to scroll at the bottom of content (else keyboard override it)
      $('#ui-keyboard-height').remove();
    };
    VKI_CONFIG.change = function(e, kb) {
      // Set first char in uppercase
      /*
       var caret = $.keyboard.caret(kb.$preview),
       end = caret.end - 2 >= 0 ? caret.end - 2 : caret.end;
       var str = kb.$preview.val().substring(end, caret.end);
       if (!/shift|lock/i.test(kb.last.key)) {
       kb.shiftActive = (caret.start === 0 || str.indexOf('. ') >= 0);
       kb.showKeySet();
       }*/
    };
  }])

Versions: keyboard#1.26.26 app/bower_components/keyboard ├── jquery#3.2.1 └── jquery-ui#1.12.1

I don't know where the problem is... On Desktop, it's working great. But on the Raspbian, it's in trouble... On Raspbian, the application is running on Chromium browser.

Thanks for your help !

TheSin- commented 7 years ago

IIRC you can add css to the keys when they are touched, my best guess is the touch driver is jumping around based on capacitance. To debug use css to see the keys light up, track the X driver's output on the touch device or use the callbacks to trigger something to logs.

My guess is you'll see the issue it's the plugin but the touch driver is reporting x,y as moving or wrongly.

I do tons of RPI dev and started with this plugin because of an RI project and getting the touch to work properly was a task in it's self.

TheSin- commented 7 years ago

BTW are you running chromium in FB or via Xorg?

steven-work-space commented 7 years ago

Hi @TheSin- Thx for your help !

I'm running Chromium via Xorg server.

Started on boot with :
@sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium/Default/Preferences @chromium --noerrdialogs --disable-translate --disable-session-crashed-bubble --disable-infobars --kiosk --disable-pinch --overscroll-history-navigation=0 http://127.0.0.1:8000/app

I'm gonna to console.log keyboard inputs. I don't know how to track the X driver's output.

Have a nice day

steven-work-space commented 7 years ago

Hi all,

I forget to mention that: When I press a key, my key is highlighted and my letter is written in my fields. When the problem occurs, other unaffected keys will be highlighted. When they become so, they are also marked in my fields. I do not think I need to look at the output of the driver. Yes ?

I really feel that it is indeed linked to the touch screen that I use.

I thought of a solution to fix the problem. If two keys are pressed almost at the same time, I only retain the first one. Assuming that it is a user action.

Could it work?

Mottie commented 7 years ago

It might be possible to use the beforeInsert function to check the times between events and block inserting closely timed values - I haven't tried anything like that yet; but to me it sounds like you might have a bad touch screen.

steven-work-space commented 7 years ago

It's a problem with the screen. I ordered a second one and found no problems. Ticket closed. Thank you for your time.