getkey function