functions to load key registers and to clear them