I am fairly certain that this is a limitation with your keyboard as the 'w' key (which I assume you are using for your walk forward button) is on the same column as your '2' key (which I assume you are using to try and switch to your pistol...) If you are using different keys, please let us know what they are, but for me using the 't' key for forward and '2' for pistol it switches just fine, then again I have a rather nice keyboard which won't give me phantom keys after only two presses on a row...
Try this, create a new text document and hold down the 'w' key (or whatever you are using for forward) and then press '2' (or whatever you are using to switch to pistol) and see if your keyboard reports the press of '2.'
So, to sum this all up, it sounds like you need a new keyboard but I am making a lot of assumptions about your key configuration. Please let us know what keys you are using and how the test goes.