jEditText | OnKeyPress lazarus / 43-Android ---------------------------------------------------------------------- cpalx · 2023-06-26 13:59 Hello how can i get on key press event? i need to capture the #13 key ---------------------------------------------------------------------- jmpessoa · 2023-06-26 19:17 What about jEditText "OnEnter"  ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.EditText1Enter(Sender: TObject);begin  //end; ---------------------------------------------------------------------- maurobio · 2023-07-01 17:53 Hi, @cpslx, The OnEnter event is triggered when the jEdit control gets focus, not when the user pressed the Enter key. You should use the OnKeyPress event for that, but that event does not exist in LAWM jEdit. OnEnter is not passed a "Key" parameter (as OnKeyPress does) which would allow to capture the key pressed (eg. #13). With best regards, ---------------------------------------------------------------------- jmpessoa · 2023-07-04 18:45 QuoteThe OnEnter event is triggered when the jEdit control gets focus, not when the user pressed the Enter key. You should use the OnKeyPress event for that, but that event does not exist in LAWM jEdit. OnEnter is not passed a "Key" parameter (as OnKeyPress does) which would allow to capture the key pressed (eg. #13). No.  "OnEnter"  handle the "enter/done/go"   specific  key   (KeyEvent.KEYCODE_ENTER = 66) To handle  jEditText  focus  use  "OnFocus": Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.EditText1Focus(Sender: TObject; textContent: string);begin    //end; ---------------------------------------------------------------------- maurobio · 2023-07-04 18:57 Hi, @jmpessoa! QuoteNo.  "OnEnter"  handle the "enter/done/go"   specific  key   (KeyEvent.KEYCODE_ENTER = 66) What's the difference between handling the enter/done/go and and triggering the OnEnter event (which is what what actually the OnEvent do)?. OnFocus will provide the contents of the edit field, not with key that has been pressed (#13 or whatever). Best regards, ---------------------------------------------------------------------- jmpessoa · 2023-07-04 20:14 QuoteWhat's the difference between handling the enter/done/go and and triggering the " event... In Android/LAMW  "OnEnter"  just handle  enter/done/go  key..... ---------------------------------------------------------------------- maurobio · 2023-07-04 20:18 @Hi, jpessoa! QuoteIn Android/LAMW  "OnEnter"  just handle  enter/done/go  key.... What are the "done" and "go" keys then? I know where the "enter" key is, but never heard of a "done" and a "go" key before. Triggering of events (like OnEnter) and pressing of the keys (on a physical or a virtual keyboard) are quite distinct. Best regards, ---------------------------------------------------------------------- jmpessoa · 2023-07-04 21:13 In Android  the  "Enter" or "Go" or "Done" are alias  to the same key... and you can get the user press action handling LAMW jEditText  "OnEnter"  event.... ---------------------------------------------------------------------- maurobio · 2023-07-04 21:20 Hi, @jmpessoa! QuoteIn Android  the  "Enter" or "Go" or "Done" are alias  to the same key... and you can get the user press action handling LAMW jEditText  "OnEnter"  event.... Please present a simple working example of how the key can be captured in the OnEnter as this will make everything clear for everyone. Best regards, ---------------------------------------------------------------------- jmpessoa · 2023-07-04 21:28 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.EditText1Enter(Sender: TObject);begin   ShowMessage('You just press key "Enter"');end; ---------------------------------------------------------------------- maurobio · 2023-07-04 21:45 Hi, @jmpessoa! A fragment of code is worth a thousand words in pidgin English.  Best regards, ---------------------------------------------------------------------- neuro · 2025-10-03 04:26 Quote from: jmpessoa on July 04, 2023, 11:28:45 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.EditText1Enter(Sender: TObject);begin   ShowMessage('You just press key "Enter"');end;   Yesterday I have installed the latest version v2.4.0f of “fpcupdeluxe”. I have recompiled my all LAMW programs with targetSdk set to 35. Now I have discovered that in all my programs in all jEditText components “OnEnter” event no longer works. As a workaround fix I have moved my program code from “OnEnter” event into “OnDone” event, and now it works. However “OnDone” event works only when virtual keyboard shows submit button with the word “Done”. When the number of visible jEditText components changes from one to more then submit button of virtual keyboard shows the word “Next” instead of word “Done” and in this case “OnDone” event fails to work. I have stopped random switches (of submit button of virtual keyboard) from “Done” into “Next” by adding the following code to OnJNIPrompt event: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i InputTextEdit.SetImeOptions(imeActionDone); // Theoretically this should set submit button to "Done", however it sets to "Enter" Additionally I have connected three events together (just in case if submit button will randomly switch from “Enter” into “Done” or “Next”): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.InputTextEditEnter(Sender: TObject);begin  InputTextEditDone(Self);end; procedure TAndroidModule1.InputTextEditNext(Sender: TObject);begin  InputTextEditDone(Self);end; Quote from: jmpessoa on July 04, 2023, 10:14:09 pmQuoteWhat's the difference between handling the enter/done/go and and triggering the " event... In Android/LAMW  "OnEnter"  just handle  enter/done/go  key..... In the latest version v2.4.0f of “fpcupdeluxe” this behavior has changed. Now “OnDone” and “OnNext” and “OnEnter” are separate events.