Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
P5.js SOME Keycodes not responding

I've been surfing through a lot of old P5.js questions and ran into this question: p5.js code isnt executing when spacebar is pressed in combiniation with up and left I tried out a few of my ideas in the editor (which didn't work), then I made this little test program:

function setup(){
  
  createCanvas(200, 200);
  
}

function draw() {
  
  background(220);
  
  textAlign(CENTER, CENTER);
  text( keyCode, width/2, height/2 );
  
  let lettersPressed = "";
  
  let toKeyCode = k => {
    
    return 65 + "abcdefghijklmnopqrstuvwxyz".split("").indexOf(k);
    
  }
  
  "abcdefghijklmnopqrstuvwxyz".split("").forEach(l => {
      
    lettersPressed += keyIsDown(toKeyCode(l)) ? l : "-"; 
    
  });
  
  text(lettersPressed, width/2, height/1.7);
  
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>

The first number is the keycode of the most recent key press. The letters/dashes after that is all the letters in the alphabet that are being pressed.

THE QUESTION

When I press down the a, b, and c key they all show up. But when I press the d key on top of that, the d key doesn't show. This is a very similar problem to the SO I linked. The weird part is you can press the e key and it works. This is a pattern throughout other combinations of keys as well. Is their a reason for this?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This has nothing to do with p5.js, it has everything to do with the physical keyboard you're using and your computer/operating system/drivers.

Keyboards can only transfer so much data, so they limit the number of keys that they report pressed at any given time. Sometimes they do this to X number of keys per area.

Watch Ben Eater's How does a USB keyboard work? for more details, as well as How does n-key rollover work?.

about 4 years ago · Juan Pablo Isaza Relatório

0

The way keyboards are wired prevents them from detecting multiple keys in certain combinations, so it will ignore the extra keys in what's known as N-key rollover. It's not p5.js at all.

You can look at this link:

https://www.quora.com/What-is-anti-ghosting-for-a-keyboard

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda