Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

iPhone numeric keyboard not working - Keyboard: 日本語 かな入力 (Japanese Kana)

Open komitake opened this issue 3 years ago • 20 comments

  • It seems not working if I input by iPhone numeric keyboard.
  • No problem on Android device for me.
  • Attached reproduction video on Demo site
  • OS: iOS 14.7.1
  • Browser: Safari
  • Inputmask version

https://user-images.githubusercontent.com/3639478/133979959-7871b0a5-f672-48f9-8855-a76fdd4dd463.MP4

komitake avatar Sep 20 '21 09:09 komitake

@komitake ,

Can this be reproduced on browserstack? I tested on browserstack Iphone 11 ios 14 safari and see no problem.

On which iphone are you testing?

RobinHerbots avatar Sep 28 '21 09:09 RobinHerbots

@RobinHerbots I'v tested with my real device.

I noticed that it's depending on the keyboard kind.

My setting is.. iPhone Settings -> General -> Keyboard: 日本語 かな入力 (Japanese Kana) iPhone Settings -> General -> Language & Region > iPhone Language: 日本語 Japanese

If I change either setting then the issue won't happen. changed Keyboard to English (US) changed Language to English (I suppose English keyboard is used automatically when Language is changed to English)

komitake avatar Sep 28 '21 13:09 komitake

@komitake ,

Probably the definitions needs to be extended for Japanese Kana.

Currently

export default {
	"9": { //\uFF11-\uFF19 #1606
		validator: "[0-9\uFF10-\uFF19]",
		definitionSymbol: "*"
	},
	"a": { //\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5 #76
		validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
		definitionSymbol: "*"
	},
	"*": {
		validator: "[0-9\uFF10-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]"
	}
}
```

RobinHerbots avatar Sep 28 '21 14:09 RobinHerbots

@RobinHerbots , It reproduces on iPad with chinesse keyboard. If switching keyboard to english, everything is working fine.

General -> Language & Region > iPad Language: English General -> Keyboard: Chinese, Traditional (Hong Kong)

iOS version: 15.1 Browser: Safari Inputmask version: 5.0.6

Hoshinokoe avatar Nov 29 '21 14:11 Hoshinokoe

@RobinHerbots ,

I found that keypress event not fired on iOS mobile devices for Janapanese, Korean and Chinese keyboards.

https://developer.apple.com/forums/thread/61607

Hoshinokoe avatar Jan 31 '22 21:01 Hoshinokoe

@Hoshinokoe ,

For mobile devices I rely on the input event and not the keypress event.

Can you have a try by forcing the input event. Add the inputEventOnly: true option.

RobinHerbots avatar Feb 21 '22 16:02 RobinHerbots

@RobinHerbots ,

inputEventOnly: true solves the issue. This setting should be added into documentation.

Hoshinokoe avatar Feb 22 '22 16:02 Hoshinokoe

@Hoshinokoe ,

Can you send me some info about the sequence of events which get fired, and also the value of the keyCode property of the events.

RobinHerbots avatar Feb 24 '22 12:02 RobinHerbots

@Hoshinokoe ,

I am especially interested in the keyCode value of the keyup and keydown event.

RobinHerbots avatar Feb 24 '22 13:02 RobinHerbots

@RobinHerbots

only keyup and keydown events ? You can provide debug version of your script and then I can back with results.

Hoshinokoe avatar Feb 24 '22 15:02 Hoshinokoe

@Hoshinokoe ,

You can use this https://codepen.io/robinherbots/pen/rNYrpzJ

RobinHerbots avatar Feb 24 '22 16:02 RobinHerbots

@RobinHerbots,

Chinese keyboard:

https://user-images.githubusercontent.com/6155797/155785307-c5a5560b-95d2-4a80-958a-e5e5a99436af.MP4

Italian keyboard:

https://user-images.githubusercontent.com/6155797/155785353-fee571d6-c80f-41cf-8c19-8ff6ad5786dc.MP4

Hoshinokoe avatar Feb 25 '22 19:02 Hoshinokoe

@Hoshinokoe ,

Can you repeat the test while typing "abc" Thx, Robin

RobinHerbots avatar Feb 28 '22 08:02 RobinHerbots

@RobinHerbots ,

No sense to do that. Chinese don't have "abc". For italian/english it will the same as "123".

Hoshinokoe avatar Feb 28 '22 09:02 Hoshinokoe

@Hoshinokoe ,

Ok, I pushed a new version. Can you have a try with it?

RobinHerbots avatar Feb 28 '22 09:02 RobinHerbots

@RobinHerbots Cursor jumps through one position and it allows to input more then required.

<script src="https://rawgit.com/RobinHerbots/Inputmask/5.x/dist/jquery.inputmask.js"></script>
<script>
    $(document).ready(function(){
    $('input[type="text"]').inputmask({ mask: "99-99-99-99"});
});
</script>

https://user-images.githubusercontent.com/6155797/156038090-73239017-29f5-48a9-a7c6-758d7ceda1d6.mp4

Hoshinokoe avatar Feb 28 '22 18:02 Hoshinokoe

Can I emulate this somewhere online?

RobinHerbots avatar Mar 01 '22 15:03 RobinHerbots

@RobinHerbots , its good question. Browserstack has small amount of supported keyboard languages (https://www.browserstack.com/question/566). I tested this issue on real device.

Hoshinokoe avatar Mar 05 '22 12:03 Hoshinokoe

Ran into the same issue on iPhone with iOS 15.4.1. Setting inputEventOnly: true solved the issue.

While debugging I found that the issue seems to be the keycode value on the keyboard event. While pressing numbers on Chinese keyboard the keycode is always 229. From what I found from browsing the code, that keycode is always ignored.

Here's a screengrab of the keyboard event values in keydown event: image

Chuli2k avatar Apr 25 '22 14:04 Chuli2k

Hi @RobinHerbots, I implemented this fix (inputEventOnly: true) but now I'm having issues with being able to clear input fields. As you can see in the video below, now, with this option set, if you try to select all the text and hit delete to clear all of it, there is always the last character left in the input field and the field is not registered as being "cleared." This behavior doesn't occur with inputEventOnly: false. Is there any option to have the Chinese/Japanese/etc. keyboards work but also not have this issue with clearing occur? Thanks.

https://user-images.githubusercontent.com/12002452/178832237-2076aab6-aef2-4b2c-814b-12c352aface4.mov

xisabao avatar Jul 13 '22 20:07 xisabao