According to the Kafka documentation:
The producer is responsible for choosing which message to assign to which partition within the topic.
According to the current state of things (Kafka>=0.10.0.1), the kafka-console-producer.sh script and the underlying ConsoleProducer java class support sending data with a key, but such support is disabled by default and has to be enabled from the CLI.
Namely, you need to set the property parse.key. Also, if you want to use something different than a tab character, use key.separator as specified in Cedric's answer.
In the end, the command line would be:
kafka-console.producer.sh --broker-list kafka:9092,kafka2:9092 \
--topic $TOPIC --property parse.key=true --property key.separator=|