Hi all,
In my program I use the “h” key to bring up a kind of “Help Menu”. This works very well but I would like to replace it by a more “standard” use of the “F1” key (keyCode = 112). Whenever I use the F1 key the “normal” Chrome help page is opened …
if (keyIsDown(112)) {
// F1 Key
helpON = true;
}
This doesn’t work the way I want disappointed: Any other possibility ?
THNX
Roland
This may be an issue with your web browser or operating system. It works fine for me in Chromium on MacOS (pressing F1 turns the background black instead of gray):
1 Like
I’m using Win10 and tested your code on Chrome and Edge. Both same result : showing result (text) in code window but also performing “unwanted” tasks as opening ‘help’ (F1), search (F3), reload page (F5), navigation keys ? (F7), full screen (F11 → acceptable) and page source (F12). I think I’m overlooking a global setting somewhere … .
Thanks for your response anyway !
I don’t have easy access to a windows machine to test this, but I updated the code slightly to prevent the default action associated with each keyboard event:
function keyPressed(e) {
e.preventDefault();
pushEvent('keyPressed', e);
redraw();
return false;
}
On my system this prevents Browser/OS level actions that would normally be triggered (for example Command+P on my system would normally trigger the browser’s print function, but this sketch prevents that). Note that the sketch window needs to have focus for this to work.
YES ! This is working. Will need a lot of editing of my sketch as I use “keyIsDown”, “keyTyped”, keyIsPressed … Probably it is a good reason to review the whole put-up of the code as now it is the result of building always on top of previous versions. Good occasion to simplify a lot !
Thanks again for your help !