Pythonでキー入力 ref: http://qiita.com/ponsuke/items/1135333350f1bbf36742