Be more explicit on patterns for TERM to avoid changes for unknown terminals.

Previously, only the prefix of $TERM was checked for "xterm" and
the like.  This is a common practice (e.g., Vim internally does
this) in order to pick up "families" of terminal settings; however,
in case future terminal types are defined that have incompatible
key codes, we now limit to variations in $TERM that should have no
bearing on key codes (e.g., "-256color" suffix).