mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
Actual build cancelled.
This commit is contained in:
23
src/components/Hangman/PuzzleWord/AddLettersRegistered.js
Normal file
23
src/components/Hangman/PuzzleWord/AddLettersRegistered.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import alphabet from './alphabet'
|
||||
|
||||
const AddLettersRegistered = (lastLetterRegistered, setLastLetterRegistered) => {
|
||||
|
||||
const addLetterHistory = (event) => {
|
||||
|
||||
const currentKey = event.key
|
||||
|
||||
if (!lastLetterRegistered.includes(currentKey.toUpperCase()) && alphabet.includes(currentKey.toLowerCase())) {
|
||||
|
||||
const array = [...lastLetterRegistered, currentKey.toUpperCase()]
|
||||
|
||||
setLastLetterRegistered(array)
|
||||
console.log(lastLetterRegistered)
|
||||
}
|
||||
|
||||
window.removeEventListener('keyup', addLetterHistory)
|
||||
}
|
||||
|
||||
window.addEventListener('keyup', addLetterHistory)
|
||||
}
|
||||
|
||||
export default AddLettersRegistered
|
||||
Reference in New Issue
Block a user