Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 10 Monaten
Letzter Beitrag:
vor 1 Jahr, 9 Monaten
Beteiligte Autoren:
Allard, Luis Antonio Gutiérrez Flores, Arie, AndyD

question on webdev ( 21)

Startbeitrag von Allard am 07.05.2016 23:30

Does anyone know if it is possible to catch what key a user has pressed. Say F6 or something

I have a situation where someone wants to use key s to do something like in a windows app but then in a webapp.



Hi Allard,

you could use jquery for that: https://api.jquery.com/keypress/

Best regards

von AndyD - am 08.05.2016 17:56
You can use a javascript function, I use the following code to capture the key pressed on the keyboard, and then you compare it to its ASCII equivalent to know which key was pressed, in my case I capture the enter when positioned in a text box, the enter ASCII code is 13, so this is my code:

// Browser procedure with JS activated
function enterPressed()
return event.keyCode;

//Code in my OnKeyPressed() of my EDT_ control
IF enterPressed() = 13 THEN

von Luis Antonio Gutiérrez Flores - am 12.05.2016 15:53
Thanks Luis,

So simpl:spos:e thanks

von Allard - am 12.05.2016 21:08

Maybe stupit question . But I cannot get it to work. Where do I place the javascript?

I added the java script code in the onfocus by turning it to JS . But in the key Up I cannot use the function.


von Allard - am 29.05.2016 15:25

I made a procedure in JS and was indeed able to call It .

So I guess that is how it works. Thanks


von Allard - am 29.05.2016 16:55
Sorry for not answering, but yes, it was a global browser procedure and then you called it where you needed it :)

von Luis Antonio Gutiérrez Flores - am 31.05.2016 15:51

A global procedure . Hmm I made a procedure I donnot know itf it was global . Tried that succesfully . Because I was able to call it ( no fault in webdev ) but it didnot do anything?

Well it does something because If I add an info it doesnot work and if I // the code of the procedure the info works.

So i will see if it is global . By the way I use php modus . But that should not matter does it ?


von Allard - am 03.06.2016 21:29
Hi I tried global and local procedure but nothing happens??

If I add this javascript code ( when I make wl into js ) then 13 is returned

var x = event.which || event.keyCode;

if I add this in a procedure like this

function enterPressed(){
var x = event.which || event.keyCode;
return x

An try to call the procedure like this

If enterPressed() = 13 then
info( "OK")

nothing happens.

What Am I doning wrong??


von Allard - am 06.06.2016 14:41
Hi Allard,

use Trace(enterPressed() ) to see what is actually returned.
You could also use the browsers debugger with F12 to get details about what is going on.

von Arie - am 06.06.2016 14:51
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.