added error and keymapping code

added error and keymapping code