The best way is digitally. You can pick up MIDI keyboards fairly cheaply. You may be able to buy or find a design for a MIDI to control voltage converter that will produce a voltage that follows the 1V/octave convention, and a gate signal. If you want to get into microcontrollers, you can make this converter fairly easily. It would get more complicated if you need to support glissando, bender or vibrato, though.
There are other ways of course. Old monophonic keyboards are based on resistor chains. The Minimoog is the only one I know in detail. It feeds a constant current into a resistor chain at a point chosen by the key that's being pressed. This produces a 1V/octave control signal directly. The gate signal is actually generated from a separate set of contacts on the Minimoog keyboard (Pratt and Read) but could easily be generated by the current source, which can provide a signal that indicates whether there is a load on it or not.
So in case it's not obvious, the keyboard has a chain of resistors of the same value, and high accuracy (1% was the best you could get in those days; this is one reason for the always-out-of-tune sound of early analogue synths) and every key is a switch that connects the resistor chain at that point to a common contact. The keyboard is open circuit when nothing is pressed, but when a key is pressed, it presents a resistance that is related to the position of the key that's pressed.
When two or more keys are pressed, one gets priority - either the highest one, or the lowest one, depending on which end of the chain is grounded. On the Minimoog, the lowest one gets priority.
Another approach would be to use a voltage divider made of a chain of resistors, with each key connecting a different point in the chain to a common output connection, but this suffers from the "pitch going weird if two keys are accidentally pressed" problem that you mentioned.
What hardware do you currently have? Do you have the physical keyboard with keytops etc? Are you planning on buying one?
Do you have any microcontroller experience?