Javascript key codes

keycode(key = NULL, code = NULL)

Arguments

key

character vector specifying keynames (default = NULL)

code

numeric vector specfiying keycodes (default = NULL)

Value

A numeric or character vector

Details

This function provides a mapping between the human-readable javascript key names and their corresponding numeric code values. If both input arguments are NULL, it returns a named numeric vector whose values correspond to the key codes and whose names correspond to the key names. If key is specified the return value is a vector with the corresponding numeric codes; whereas if code is specified the output is a character vector containing the corresponding key names. If neither argument is NULL the function throws an error.