Just because it continues when you unplug your keyboard doesn't necessarily mean the keyboard isn't the problem. The only way to really know for sure is to plug in a different keyboard and then reboot the computer.
The reason: your keyboard sends a "9 is being held down" signal to the computer, and the computer keeps doing that until it gets a "9 has been let go" signal. If that signal never arrives, it will keep typing 9 even if you unplug the keyboard.