import msvcrt
import random
import dircache
import os
import time
from pygame import mixer

while True:
    bokstaver = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    key = msvcrt.getch()
    if key in bokstaver:
    	dir = 'bokstaver'
	filename = random.choice(dircache.listdir(dir))
	path = os.path.join(dir, filename)
	print str(path)
        mixer.init()
        mixer.music.load(path)
        mixer.music.play()
	time.sleep(0.9)
    
