Yes, you'll want to use keypressed.
From commands.rtf:
keydown(key) "the specified key is pressed (0..10: up,left,down,right,S,A,D,M,tab,Q,P)"
So, yes, Q would be 9.
If you want to use other letters not specified in the above info, you would use keydown2.
The syntax for keydown2 is similar, keydown2(keycode,ignorecase);
So, with that, and using the keycode() thing, you can do things like:
NPC Code:
if (keypressed) {
if (keydown2(keycode(x),true)) {
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,Stuff,;
}
}
In that code, it would check to see if a key was pressed (keypressed), then would check in the x button was pressed (keydown2(keycode(x),true)) and would ignore the case, so X would work as well.
If all that was true, it would do the triggeraction.