1

Try this code to reproduce the problem (only event fired will be printed in console with any key but ALT or CTRL, and others but I just need alt to work):

<!DOCTYPE html>
<html>

    <body onkeypress="openTab(event);">

    <h1>My First Heading</h1>

    <p>My first paragraph.</p>

    <script> function openTab(e) {
        console.log('event fired');
        if (e.altKey) { 
            console.log('event alt key');
            if (e.charCode == 114 || e.charCode == 82) { 
                console.log('event alt key plus R');
            }
        }
    }
    </script>
    </body>
</html>

I though I was doing something wrong but I added a logger in the function and it prints with any key, I mean it works pressing any key but ALT, or CTRL, or SHIFT, I don't know if this is a problem with the version of mozilla.. or whats going on. Because when I press alt I don't get the event but the browser menu opens up, maybe there is a way to configure this?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
BugsForBreakfast
  • 712
  • 10
  • 30
  • So in a plain simple html file (non-jsf) with `` it works? And nothing PrimeFaces related in here. And it works in chrome? And in firefox 67? – Kukeltje Sep 19 '19 at 17:48
  • @Kukeltje I will try that ;p – BugsForBreakfast Sep 19 '19 at 19:05
  • @Kukeltje I did it on a plain html and it still doesn't works, try the code I will add to my edit, it only prints lol with any key but ALT or CTRL... can you see if it works for you on your browser? it detects alt? – BugsForBreakfast Sep 19 '19 at 19:15
  • No idea... That is something for the javascript and html support people to find out (I only do JSF/PF things (also if the javascript is related, here it is not) So effectively not JSF related. Maybe remove all that and the jsf tag too to not deter the javascript people... And what about the older Firefox versions (Mozilla is the organisaztion)? What about Chrome? – Kukeltje Sep 19 '19 at 19:49
  • @Kukeltje yes it works in the older firefox version we use with PF 3.5 I was hoping someone could tell me if it is possible to make a configuration on the browser or something mate, I will wait then =) also it doesn't work with chrome version Versión 61.0.3163.100 – BugsForBreakfast Sep 19 '19 at 19:51
  • PF is not important... Try the PLAIN HTML version there... And also post which browser version it did work on... Be specfic....And please format your code... indentation wise... – Kukeltje Sep 19 '19 at 19:52
  • @Kukeltje Okay I will, need to wait for my partner he has the PC with older version, will let you know, this is the last thing for the migration from 3.5 to 7.0 to be completed hehe – BugsForBreakfast Sep 19 '19 at 19:54
  • And did you try searching for 'firefox alt keypress problem'? On the first page in google: https://www.fxsitecompat.dev/en-CA/docs/2018/non-printable-keys-no-longer-fire-keypress-event/ and https://stackoverflow.com/questions/25952260/event-altkey-not-working-in-chrome-and-ie after some more searching – Kukeltje Sep 19 '19 at 20:08
  • @Kukeltje thanks brother, you also helped me with it :), I will check out those links – BugsForBreakfast Sep 19 '19 at 21:02
  • @Kukeltje hey mate, good news it was indeed the browser version, it works with mozila from 38 to 50, so the migration is indeed finished <3 :) but still it would be good if someone can make it work in this new version of mozilla – BugsForBreakfast Sep 20 '19 at 16:16
  • Great.... but read the links.... it is all in there and very, very simple.... – Kukeltje Sep 20 '19 at 17:05
  • @Kukeltje yeah I see its indeed they removed them, hmm gonna try keydown – BugsForBreakfast Sep 20 '19 at 19:08
  • 1
    @Kukeltje I managed to make it work with keydown for any version of mozilla, the problem is that, for some reason using the operator && like so: if (e.altKey && e.keyCode == 82) that is combination for alt + r, makes the application broke, and i get no errors on console mate, so i have to do the if with the alt key, and inside that if the others ifs with the keycodes, strange right? you have any idea? – BugsForBreakfast Sep 20 '19 at 19:49
  • @Kukeltje hey did u read comment? – BugsForBreakfast Sep 20 '19 at 21:27
  • Yes I read it but sometimes have other things to do. And no, sorry, we don't use keyboard events like this. Create a new question and see if others know something – Kukeltje Sep 20 '19 at 22:05
  • @Kukeltje okay bro, it works tho its just that it shouldn't give problem with "and" statement, I will ask :) – BugsForBreakfast Sep 20 '19 at 22:21

0 Answers0