Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

Support for setting iOS UIReturnKeyType #54

Open
anemitoff opened this issue Dec 15, 2014 · 47 comments
Open

Support for setting iOS UIReturnKeyType #54

anemitoff opened this issue Dec 15, 2014 · 47 comments

Comments

@anemitoff
Copy link

We really need a feature to allow an ionic application to select whether the return key on the iOS keyboard says "GO" or one of the other allowable values such as "Next" (see below for other options). I know others have requested this functionality in the ionic forums but it seems that this keyboard plugin is the proper target for such a request.

The allowable values are:
typedef enum : NSInteger { UIReturnKeyDefault , UIReturnKeyGo , UIReturnKeyGoogle , UIReturnKeyJoin , UIReturnKeyNext , UIReturnKeyRoute , UIReturnKeySearch , UIReturnKeySend , UIReturnKeyYahoo , UIReturnKeyDone , UIReturnKeyEmergencyCall , } UIReturnKeyType;

@antonshevchenko
Copy link

+1

@ghost
Copy link

ghost commented Jan 27, 2015

I don't think this is currently possible considering the app's hosted in a UIWebView. There doesn't seem to be any way to convince WebKit to use a specific return key for a field, and there's definitely no way of doing it through Objective-C.

All the plugin has access to is a UIWebView and a UIViewController. Maybe some kind of dirty hack could be implemented to force UITextFields associated with DOM elements to have a certain key type, but I doubt this would be particularly stable or future proof.

@antonshevchenko
Copy link

I noticed that putting an <input> field in <form>s will automatically adjust the keyboard's return key.

For instance, the following would display the word "Search" in the return key:

<form>
  <input type="search">
</form>

@ghost
Copy link

ghost commented Jan 29, 2015

Yes this seems to work for simple use cases, the main issue is achieving the 'next' functionality you can do in native iOS apps. I don't think this is currently possible without resorting to private APIs as Safari uses an accessory bar to achieve this instead.

@tlancina
Copy link
Contributor

Duplicate of #20. I spent a lot of time on this and even with private APIs couldn't get it to work. As @lyptt said, the 'next' functionality for the return key doesn't exist in mobile Safari (as far as I know), instead it uses the accessory bar.

I'm going to be revamping a lot of keyboard stuff soon so I'll take another look, but closing this for now.

@mlynch mlynch reopened this Apr 9, 2015
@lbickston
Copy link

I see this was reopened on April 9. Any progress on this?

@moultz
Copy link

moultz commented Jul 14, 2015

Looks like this was reopened, any progress/update?

@tlancina
Copy link
Contributor

It was reopened in hopes that WKWebView would expose more access to the keyboard (or implement UITextInputTraits), but that wasn't the case. As far as I know this is still not possible, but I would really love to be wrong!

@iischajn
Copy link

+1

@janpio
Copy link

janpio commented Oct 22, 2015

+1

2 similar comments
@daco
Copy link

daco commented Oct 29, 2015

+1

@bensinclair
Copy link

+1

@feliperbroering
Copy link

+1

@Findiglay
Copy link

+1

11 similar comments
@gkucsko
Copy link

gkucsko commented Jan 29, 2016

+1

@smakys
Copy link

smakys commented Feb 4, 2016

+1

@FabricioFFC
Copy link

+1

@josenicomaia
Copy link

+1

@egkozlov
Copy link

+1

@b264
Copy link

b264 commented Mar 1, 2016

+1

@triasrahman
Copy link

+1

@razorcd
Copy link

razorcd commented Mar 3, 2016

+1

@EmilioVillante
Copy link

+1

@jasongilmour
Copy link

+1

@donaldG21
Copy link

+1

@popaprozac
Copy link

+1

3 similar comments
@bengro
Copy link

bengro commented May 3, 2016

+1

@kernelLove
Copy link

+1

@TawabG
Copy link

TawabG commented May 9, 2016

+1

@avatsaev
Copy link

avatsaev commented May 31, 2016

the fact that is issue is still open shows how much of a garbage framework ionic is

@josenicomaia
Copy link

josenicomaia commented May 31, 2016

@avatsaev It's simple. Just PR it!

@plenartech
Copy link

+1

1 similar comment
@EralpB
Copy link

EralpB commented Aug 19, 2016

+1

@yaswant-dowlut
Copy link

+1

At least we should have the ability to switch to the next field when the return key is clicked, and perform an action when the return key is hit on the last field.

@yaswant-dowlut
Copy link

yaswant-dowlut commented Aug 26, 2016

A workaround to get the behaviour I described in my previous comment working is as follows. Note that I have assumed that jQuery has been included in the project. But this example can also be adapted to work with jqLite alone as well.

Add the following line in config.xml:

<preference name="KeyboardDisplayRequiresUserAction" value="false"/>

Create the following directive:

.directive(‘iosReturnHandler', function() {
  return {
    restrict: 'A',

    link: function(scope, element, attrs) {
      element.keyup(function(e) {
        if (e.which == 13) {
          var nextSibling = element.next('input');

          if (nextSibling.length == 0) {
            scope.$apply(function() {
              scope.$emit(‘ios-last-return-clicked');
            });

            return;
          }

          nextSibling.focus();
        }
      });
    }
  }
})

Then add the directive to input fields on which you want the return key of the keyboard to be handled:

<input type=“text” id=“input1” ios-return-handler />
<input type=“text” id=“input2” ios-return-handler />
<input type=“text” id=“input3” ios-return-handler />

This will cause the focus to be automatically changed to the next input when the return button is clicked on the keyboard. When the last input is reached and the return button is clicked again, the event ios-last-return-clicked will be emitted which you can catch in your controller to perform some action.

I hope this helps.

@vmunich
Copy link

vmunich commented Nov 12, 2016

+1

@kyle-apex
Copy link

+1

If it's useful for anyone, I created the following directive that works to tab when "Go" is clicked in RC4 when adding a tabOnGo directive to ion-input.

@Directive({
    selector: '[tabOnGo]'
})

export class TabInputDirective {

  inputRef: TextInput;
  constructor(inputRef: TextInput) {
    this.inputRef = inputRef;
  }

  @HostListener('keydown', ['$event']) onInputChange(e) {
    var code = e.keyCode || e.which;
    if (code === 13) {
      e.preventDefault();
      this.inputRef.focusNext();
    }
  }
}

@adamiprinciples
Copy link

+1

@ghost
Copy link

ghost commented Feb 6, 2017

@kyle2829 Where are you importing the TextInput type?

@kyle-apex
Copy link

@emersonstewart import {TextInput} from 'ionic-angular';

@ghost
Copy link

ghost commented Feb 7, 2017

Ah, easy enough. Thanks!

@ddoerr
Copy link

ddoerr commented Apr 21, 2017

+1

This is super important for our project!

@THEDOWNCOUNTRY
Copy link

Any Solution on this?

@entomb
Copy link

entomb commented Jun 16, 2017

please please please please please please

@jdnichollsc
Copy link

+1

@jdnichollsc
Copy link

What do you think @EddyVerbruggen?

@tanohzana
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests