Is it possible to have two key pressed at the same time ?

edited February 2016 in Questions about Code

This is a part of a little program i made so that when you press and hold a key, letters move and stop where i decided to to form a word. It works actually, but i wanted to try a way to make that when you press for example the 'b' key, the letters for one word move, when you press another key, here the 'n', the letters from the other word move, but you'd have to press and hold both keys to have them stop and form words. But it seems that the information of two keys pressed at the same time cannot be handled, and is understood as one pressed after another.. Or else there is a mistake in my code. So does anyone knows how is it possible to make something by holding two keys at the same time ? or see where i went wrong here ? (feel free to tell me if what i say is understandable or if you need more info, i'm kind of new to Processing so i don't really know what people need to understand the issue)

for(Lettre L : corps){ L.affiche(); if (keyPressed) { if (key == 'b') { L.bouge(); L.collision(); } } }

for(Lettre L : ame){ L.affiche(); if (keyPressed) { if (key == 'n') { L.bouge(); L.collision(); } } }

if (keyPressed) { if((key == 'b')&&(key == 'n')){ for(Lettre L : ame){ L.arret(); } for(Lettre L : corps){ L.arret(); } } }

Tagged:
Sign In or Register to comment.