Problems like these can be a nightmare to diagnose because could be anything from a loose connection to a faulty keyboard.
In fact my first suggestion would be to replace the keyboard if you have one handy to quickly eliminate it. It's quite common for keyboards to go down.

Next would be to do a Re-install of mach3 and any plug-ins if it's using any because I've seen it do things like this before. Save your current profile XML and re-install mach3 then load XML back in and you won't have to re-set anything.

After that it's just a case of check all wires in case loose or damaged. Then if still not playing nice then I've no idea other than a computer issue which I very much doubt.!