You could do something like this:
if (dbKeyState(scanCode)==1){
while(dbKeyState(scanCode)==1){dbSync();}
//Change weapons or whatever.
}
The only problem this presents the time the program will hang, updating the screen but nothing else, while the key is down. A better effect could be done using a boolean variable.
//Outside of your loop
bool keyIsPressed;
//Inside the loop
if ((dbKeyState(key)==1)&&(!keyIsPressed)){keyIsPressed=1;}
if ((dbKeyState(key)==0)&&(keyIsPressed)){
keyIsPressed=0;
//Change weapons or whatever.
}
The second system is superior, because the game can continue to function while the key is down.
My site, for various stuff that I make.