bydsky
bydsky

Reputation: 1794

JS keydown keyup keypress event doesn't work on IOS8 when using third party IME

$(window).keypress(function(event) {
  alert(event.which);
}

On IOS 7, this works when using system default IME, but doesn't work when using third party IME. It seems the third party IME doesn't send keydown/keyup/keypress event.

Any workaround to monitor an Enter key pressed?

P.S. This issue is similar to iOS 8 3rd party keyboards don't register javascript/jQuery keyup, keypress, keydown etc, but any workaround to monitor 'Enter' key pressed event?

Upvotes: 0

Views: 1666

Answers (1)

bydsky
bydsky

Reputation: 1794

I figure out a workaround

  $("#textarea").on('input propertychange paste',function(e){
    var input = e.currentTarget.value;
    if(input[input.lenght -1] == '\n') {
      //do something
    }
  })
  1. Use textarea replace input
  2. Add 'input propertychange paste' listener on textarea
  3. check if Enter is the last character of the textarea value

Upvotes: 1

Related Questions