Proper Rendering of KEYBOARDS is an Important UX

Mohith Gupta
JavaScript in Plain English
4 min readJan 29, 2023

--

HTML Input tag Image

Yes, I hate it when I do not get a keyboard with just numbers when a website/app asks for a phone number, PIN code, etc.

Not just that, a relevant keyboard for the respective input field should be rendered to give a user the best experience he/she can get and the type attribute in HTML does just that.

For example, a keyboard with '@'for an email field and
a keyboard with '/','.' for typing in a URL, etc.

The “type” attribute of the input tag provides a lot of information to the browsers including what kind of keyboard to display for devices with onscreen keyboards such as phones, tablets, etc. Let’s take a look at some of the values it accepts in detail.

NOTE: The keyboards rendered may differ from what you see in the below images. It might be due to different reasons — different browsers, their version, or your default/custom settings or using Android/IOS.

1. Numeric Keypad

This is ideal for inputs that require just numbers and no letters such as phone numbers, PIN, credit card numbers, etc.

<input type="numeric">

Numeric Keypad on Android

2. Standard Tele Keypad

You can also use “tel” if you want * and # and alphabet as they are present on a dial pad.

<input type="tel">

Tele Keypad on Android

3. Email field

It brings the @ character into the keyboard, as well as the dot (.) character.

<input type="email">

Email Keypad on Android

4. Typing a Web Address

The keyboard comes with a handy shortcut for users to append TLDs (e.g. .com) and the keys that are typically used in web addresses, like the dot (.) and forward slash (/) characters.

<input type="url">

URL Keypad on Android

5. Date and Time

Don’t make your user suffer just to enter a date, use type='date' and make their work easier instead. Similarly, you can use type=’time’for the time field and also add them for both functionalities together as
type='datetime-local' .

Date and Time Keypads on Android

6. Forms? Search? Filter feature?

The keyboard shows an Enter key, useful for forms submission, a search feature, etc.

<input type="search">

Search Keypad on Android

Bonus

<input type="password"> → Should be used for any sensitive fields like passwords, credit/debit card CVV, etc.

<input type="color"> → Renders a color picker that you can customize through javascript.

Wrappity wrap up time

The type attribute is very diverse. It lets you change the keyboards, upload files, hide the field, pick a color, and a lot more. You can read the MDN docs if you are curious about them.

Thanks for reading till the end. Hope you learned something useful.

Please consider showing your appreciation by providing feedback and suggestions in the comment section.

If you are pleased too much, you can always buy me a coffee 😉

buy me a coffee link

You can take a look at some of my previous posts that I’m proud of :) here

6 Extensions That You Might Not Know But Can Save Hours of Your Time
The Best Readme Generators for Your GitHub Profile
Script to download the “download restricted” files of Google Drive

Play YouTube Videos on VLC with Just 1 Click
I Hacked the Chrome Dinosaur Game. Here’s How I Did It

See you in the next one. Arrivederci!

For further doubts or anything else, you can find me on Twitter or ping me at mohithguptak@gmail.com

More content at PlainEnglish.io. Sign up for our free weekly newsletter. Follow us on Twitter, LinkedIn, YouTube, and Discord.

Interested in scaling your software startup? Check out Circuit.

--

--