On screen keyboard to open the numpad

Hi, I am using libgdx for my dice game in which you have to insert a three digit number with numbers in the range of 0-6.

When I google on how to have the on screen keyboard show numbers when opened they tell you to set the keyboard type of a textfield on numbers. On the TextField class in multi os engine this would look like:

I created my own version of IOSInput.java below and added the above line to try and get the keyboard in numbers mode:

However it doesn’t matter which of the UIKeyboardType enum values I pass the keyboard always opens in letter mode.

Any idea how to get the onscreen keyboard to open as a phone number ish dialog box?

Tjere is no numpad on ipad. You will have to create your own UI control for that. There are couple of those on github

My app is an iPhone app though.

Got it working! Will post a code snippet on what to change when I cleaned my project up… It was simple, I was modifying the wrong part.

It did worked on iphone for me. I don’t remember details but it was a top answer about numeric keyboard on ios or objectivec on stackoverflow.

In my custom IOSInput fork class, I added the textField.setKeyboardType(UIKeyboardType.NumberPad);

public void getTextInput(TextInputListener listener, String title, String text, String hint) {
    buildUIAlertView(listener, title, text, hint).show();

/** Builds an {@link UIAlertView} with an added {@link UITextField} for inputting text.
 * @param listener Text input listener
 * @param title Dialog title
 * @param text Text for text field
 * @return UiAlertView */
private UIAlertView buildUIAlertView (final TextInputListener listener, String title, String text, String placeholder) {
    UIAlertViewDelegate delegate = new UIAlertViewDelegate() {
        public void alertViewClickedButtonAtIndex (UIAlertView alertView, @NInt long buttonIndex) {
            if (buttonIndex == 0) {
                // user clicked "Cancel" button
            } else if (buttonIndex == 1) {
                // user clicked "Ok" button
                UITextField textField = alertView.textFieldAtIndex(0);

        public void alertViewCancel (UIAlertView alertView) {

    // build the view
    final UIAlertView uiAlertView = UIAlertView.alloc().init();

    UITextField textField = uiAlertView.textFieldAtIndex(0);
    if (title.equals(CallInputDialog.ENTER_YOUR_CALL)) {

    return uiAlertView;

The CallInputDialog.ENTER_YOUR_CALL class is my dialog class for number imput that brings up the keyboard. So I detect when that title is set to modify the keyboard type.