0
$(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?

Community
  • 1
  • 1
bydsky
  • 1,604
  • 2
  • 14
  • 30
  • http://stackoverflow.com/questions/18985117/onkeyup-event-in-safari-on-ios7-from-a-bluetooth-keyboard This seems to be similar to your problem. Perhaps you may try to use the .onkeypress event instead. – briosheje Mar 09 '15 at 15:36
  • this is different, the key press event is not triggered when using third party IME in IOS, but it works fine with system default IME – bydsky Mar 09 '15 at 15:52

1 Answers1

1

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
bydsky
  • 1,604
  • 2
  • 14
  • 30