Instead of `$key` I'd use `$char`.