edited dead key logic; linted and DRYed