Jump to content

Key event not firing when pressing Enter on Android virtual keyboard


snow

Recommended Posts

I changed TabStop to false for both Controls in the sample project above.
Inside TUniComboBox it works, inside TUniEdit focus still changes to the next control (no key event is fired) when pressing the virtual button.

Link to comment
Share on other sites

31 minutes ago, Sherzod said:

Need to analyze it again then.
Perhaps gboard is not working correctly somehow, don't know.

@snow and @Sherzod, maybe this will point some of solution or traubles

 

https://stackoverflow.com/questions/58303424/onkeyup-doesnt-handle-enter-from-hard-keyboard

Use dispatchKeyEvent to handle enter:

override fun dispatchKeyEvent(event:KeyEvent):Boolean {
   if (event.getAction() === KeyEvent.ACTION_UP)
   {
      Toast.makeText(this,event.getKeyCode().toString(),Toast.LENGTH_SHORT).show()
      return true
   }
}

or https://www.outsystems.com/forums/discussion/33623/javascript-to-detect-enter-key-press-in-mobile-app/

document.getElementById("Input_TextVar")
    .addEventListener("keyup", function(event) {
    event.preventDefault();
    if (event.keyCode === 13) {
        $actions.SearchMember();
    }
});

or https://www.outsystems.com/blog/posts/create-input-mask-for-mobile/

html: <input type="text" id="credit-card-mask" />

javascript:

js ------ start

var input = document.getElementById('credit-card-mask'),
    oldValue,
    regex = new RegExp(/^\d{0,16}$/g),
    mask = function(value) {
      var output = [];
        for(var i = 0; i < value.length; i++) {
          if(i !== 0 && i % 4 === 0) {
            output.push(" "); // add the separator
          }
          output.push(value[i]);
        }
        return output.join("");
    },
    unmask = function(value) {/^\d{0,16}$/g
      var output = value.replace(new RegExp(/[^\d]/, 'g'), ''); // Remove every non-digit character
      return output;
    },
    keydownHandler = function(e) {
      oldValue = e.target.value;
    },
    inputHandler = function(e) {
          var el = e.target,
               newValue = el.value
          ;
          newValue = unmask(newValue);
          
          if(newValue.match(regex)) {
            newValue = mask(newValue);
            el.value = newValue;
          } else {
            el.value = oldValue;
          }
    }
;

input.addEventListener('keydown', keydownHandler );
input.addEventListener('input', inputHandler );
js ------- end

 

declared android 11 bug: https://community.anytype.io/t/enter-key-doesnt-work-at-all-on-external-keyboards-on-android/1354/10

https://forum.jquery.com/portal/en/community/topic/how-to-get-a-enter-key-event-by-the-android

  • Like 1
Link to comment
Share on other sites

16 hours ago, Sherzod said:

@snow

function afterrender(sender, eOpts)
{
    sender.inputEl.dom.setAttribute('enterkeyhint', 'done');
}

 

Thank you so much... that did the trick!!!

Thanks to everyone involved for your support. Greatly appreciated!!!

  • Thanks 1
Link to comment
Share on other sites

8 minutes ago, Sherzod said:

In what place exactly?

In my case I want to click some button on the form and it will change the property of the text field. I will do that with addJS (if is possible).

I will leave the functionality of the stock Android keyboard, but when I need to, I will change this property of the text field

'enterkeyhint' 'done'
Link to comment
Share on other sites

19 minutes ago, irigsoft said:

In my case I want to click some button on the form and it will change the property of the text field. I will do that with addJS (if is possible).

For example:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniSession.AddJS(UniEdit1.JSName + '.inputEl.dom.setAttribute("enterkeyhint", "done");');
end;

image.png.fe0ff63a6fea70a21a7db86f1c9b3a36.png

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...