Fix bug about key detection