key press codes in JCEF browser

Having problems with building or using the JCEF Java binding? Ask your questions here.

key press codes in JCEF browser

Postby ramyakrishnan » Tue Oct 20, 2015 11:04 am

Hi ,

I have a single browser on top of my Java Swing Frame and I am trying to catch keycodes on this browser containing a HTML page using Javascript. The keys I am reading are the "left" and "right" arrow keys. For which, I am using the keycode 37 and 39. This keypress seem to work well in normal browsers like IE , Firefox and Chrome. However, on my CEF browser instance , the keycode corresponds to 255 for all the arrow keys. I am trying to understand why this is the case.

NOTE: keycodes for enter, backspace, A-Z and numbers seem to work fine. The arrow keys, shift,alt, F-1 to F-12 keys and num unlocked 1-9 keys all correspond to 255. Should I change some setting i my JCEF browser instance for this ?

I use a normal en-US Keyboard.
snippet of my code :

Code: Select all
{
if(target.keyCode ===37) {
console.log("left key pressed");
}  else if (target.keyCode===39){
console.log("right key pressed");
}
...//For all other keys
console.log(target.keyCode);
}
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: key press codes in JCEF browser

Postby magreenblatt » Tue Oct 20, 2015 11:32 am

What OS and JCEF version? Are you using windowed or off-screen mode?
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: key press codes in JCEF browser

Postby ramyakrishnan » Tue Oct 20, 2015 11:36 am

Windows 7 and yea I am in off screen rendering mode , and JCEF 3.2~
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: key press codes in JCEF browser

Postby magreenblatt » Tue Oct 20, 2015 11:39 am

ramyakrishnan wrote:Windows 7 and yea I am in off screen rendering mode , and JCEF 3.2~

Are the key codes correct if you used windowed mode? If so, then it's probably in a bug in the off-screen keyboard handling.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: key press codes in JCEF browser

Postby ramyakrishnan » Tue Oct 20, 2015 11:40 am

yes, I have another application that uses the windowed mode, and I tried out the HTML there and I could see the keycodes come out correctly.
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: key press codes in JCEF browser

Postby magreenblatt » Tue Oct 20, 2015 11:53 am

OK, please add a JCEF bug and link this thread. Pull requests to fix the issue are also welcome.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: key press codes in JCEF browser

Postby ramyakrishnan » Tue Oct 20, 2015 12:10 pm

ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: key press codes in JCEF browser

Postby magreenblatt » Tue Oct 20, 2015 12:19 pm


Thanks :) You can look CefBrowser_N.cpp SendKeyEvent as a starting point: https://bitbucket.org/chromiumembedded/ ... N.cpp-1232
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 18 guests

cron