Mottie / Keyboard

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

locale option support #783

Open tirolel opened 4 years ago

tirolel commented 4 years ago

Hi @Mottie.

Iam wondering if the keyboard does allow this scenario.

Iam using numbro to support locale options that can be used on my webapp. I have already defined some languages(decimal & thousand seperators) in numbro.

Is there anyway I can specify an option to keyboard about what is my decimal & thousand seperators? So when I show a custom num layout, it should validate the number regarding the defined option?

E.g. A user with from Belgium has these options: delimiters: { thousands: " ", decimal: "," }

When the user clicks an input field, it should show the numeric keyboard with the given "," decimal seperator & and if the user enters "1000.00" , it should be like "1 000,00". Also its important to user can add only single decimal.

Can this be done?

Thanks in advance! Best regards.

Mottie commented 4 years ago

Hi @tirolel!

I guess it's not super-obvious, or documented that well, but the display option has a dec setting (demo)

display: {
  // Decimal point for num pad (optional), change '.' to ',' for European format
  dec: ".:Decimal";
}

So for a Belgium keyboard, you can use dec: ',:Decimal'. I did try to include the common formatting in the language files (e.g. German), but not all languages have corresponding files.

The {dec} key is set up to only allow the user to type in that decimal character once. You just have to be cautious not to also include the comma key in the layout as it isn't disabled.

tirolel commented 4 years ago

Thank you @Mottie for your fast response.

Yes I see and I just have tested the decimal option, and works flawlessly! The reason is, I do have a screen is very small(480x270) and I made custom layouts for each language(tough work)

Also I have a question about a feature(s). Can i add my own custom button?

Mottie commented 4 years ago

Yes, they are called action keys.