How to run my function when ctrl/command + ) is pressed

Does anyone know how to do this:

When the command or ctrl key and ) is pressed, I want to run the terminal() command

Hi @ChickenG1ttrDev thanks for your question.

Can you share a link to your Repl?

I see this is in the HTML/CSS/JS category so assume you are wanting to access dev tools console, is that correct? If not can you explain fully what it is you are trying to do?


Add this code to your page:

document.onkeypress = (event) => {        // listens for new key presses
  if ((event.ctrlKey || event.metaKey) && event.key == ")") terminal();
  // above code looks for control/command and ) key pressed

Try this

document.addEventListener("keydown", (e) => {
    if (e.key.toLowerCase() === ")" && e.ctrlKey){
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.