Welcome! Log In Create A New Profile

Advanced

WB12 - how to detect ENTER key in an edit control

Posted by Arie 
Hi,

I need to know when the user pressed ENTER in an edit control.
I see some events like keyup,keydown and keypressed, on the browser side. But the KeyPressed() function is not available in WB.
how can I detect which key is pressed ?

Arie
Marc De Swert
Re: WB12 - how to detect ENTER key in an edit control
January 05, 2009 01:14PM
Hi Arie

in some of the programs here we use to determinate the <F12> button to print a printscreen

what do you need=
1 in the project initialisation set the next lines:
EXTERN "winconst.wl"
EXTERN "keyconst.wl"
keyconst is needed voor the key ,,,

on the screen where you want to trigger create a local procedure, we use tehe global procedure printscreen,, to print the screen

FUNCTION lp_CheckKey(p_Mess is int, p_Par1 is int, p_Par2 is int)
Info(p_Par1) // here you get the number of any key you stroke
IF p_Par1 = 123 THEN //Functietoets <F12> ingedrukt
EndEvent(gv_EventPrint)
gp_PrintScreenLandscape(Handle(), "Web_UbenchInfo.IMG_ExpAfdruk" )
gv_EventPrint = Event("lp_CheckKey", "*.*", WM_KEYDOWN)
END


at the declaration section of that windew create the globale variabele
GLOBAL
gv_EventPrint is int = Event("lp_CheckKey", "*.*", WM_KEYDOWN)



that's all!

Marco Bruto :xcool:
Marc,
unfortunaltely this does not work in webdev, only in windev.
I was looking for a webdev solution.
Arie
Fabrice Harari.pcs.crosspost
Re: WB12 - how to detect ENTER key in an edit control
January 08, 2009 02:09PM
Hi Arie...

You need to use javascript code to do that... If you don't find it, lt
me know, I have that somewhere (just need to remember where :-) )

best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

More information on [www.fabriceharari.com]


Arie Mars wrote:
> Marc,
> unfortunaltely this does not work in webdev, only in windev.
> I was looking for a webdev solution.
> Arie
>
Message forwarded from pcsoft.us.windev
Fabrice,
I (Google) found lots of examples on "javascript detect key pressed". I tried a few things, but I'm new on javascript (and Wcool smiley.

I'm able to create an event handler, which should give me an event-object, holding a 'keycode'. But this event-object is always null in my case....

For now I use a hidden link-control. It has a property "Use 'Enter' as shortcut". Not so nice, but it works.

So: if you can find your example, please post it here.

Arie
M. Beaven
Re: WB12 - how to detect ENTER key in an edit control
January 08, 2009 03:57PM
Hi Arie,

I believe you want to put the following JS code in the "onkeypress" event of your edit control:

e=(document.all? event.keyCode:event.which);
TestIfEnter(e);

Fabrice gets the credit- I just found it quicker.

Regards,

-Marc
Jan Kanters.pcs.crosspost
Re: WB12 - how to detect ENTER key in an edit control
January 09, 2009 07:47AM
please have a look in the WEBDEV forum where I posted an answer about the ENTER key...

Message forwarded from pcsoft.us.windev
ocakici
Re: WB12 - how to detect ENTER key in an edit control
February 02, 2009 08:22AM
create a browser procedure in Javascript, and call it from the keyPressed browser process of the edit control.. the following would return true if enter key is pressed.

function enterPressed()
{
var evnt = event || window.event;
var code = evnt.charCode || evnt.keyCode;

return (code == 13);
}
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: