Is there a reason for using `charCodeAt()` instead of simply:

    if (key >= 'A' && key <= 'Z') {

If `charCodeAt()` is required, instead of the hard-coded numbers (65 and 90), the following might be more readable

    if (key.charCodeAt() >= 'A'.charCodeAt() && key.charCodeAt() <= 'Z'.charCodeAt()) {

At least one doesn't have to consult an ASCII table to verify the values. (Also, the `0` isn't strictly required since it's the default value.)