keyboard - Detecting multiple key presses in C# and XNA 4.0 -


i want detect if specific set of keyboard keys being held down @ once in c# , xna 4.0. i'm doing following code:

keyboardstate keystate = keyboard.getstate();  if(keystate.iskeydown(keys.s) && keystate.iskeydown(keys.k) && keystate.iskeydown(keys.i)) {     //do } 

this code detects if user pressing "s", "k" , "i" @ once. however, i've noticed code worked fine on 1 computer (windows 8.1 laptop), not on (windows 8 desktop). additionally, wanted if statement check if user holding down p key ("s", "k", "i" , "p" @ once), when adding fourth condition (keystate.iskeydown(keys.p)), code didn't work on either computer. why code not work on multiple machines? , why glitch , not work @ when trying detect more 3 keys @ once?

this hardware problem - called keyboard ghosting -, not software problem. experience, commonly happens 3 keys down, , 4th key breaks conventional keyboards. link detailed explanation of problem, , test see if it's keyboard ghosting you're experiencing.

there's nothing can in code since it's hardware problem, except redesigning fits hardware, i.e. not require 3 key downs, or different keys...

if really want code work, buy keyboard 6-key rollover(6 keys maximum) or n-key rollover(all keys on keyboard). feature means keyboard's keys can pressed @ once simultaneously, while keys still detected computer.

oh, , here excellent video explains problem in simple way.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -