Hello, I am on Task 250 at stage 6. When I run my code, the terminal window opens but it seems to hang. When I submit the task I get the error: "The callback function passed into term.on should increment the state.gold when the G key is clicked".
my handler.js file:
export const handleKeyPress = (term, state) => {
return (name, matches, data) => {
const key = String.fromCharCode(data.code);
if (key === 'g' || key === 'G') {
state.gold++;
}
}
}
My gameEngine.js file:
import {init} from './functions.js';
import {handleKeyPress} from './handlers.js'
export const startMiningGame = (term, state) => {
init(term);
term.on('key', (name, matches, data) => {handleKeyPress(term, state)});
handleKeyPress(term, state);
}
My functions.js file:
export const init = (term) => {
term('Welcome to the mining game!');
term.clear();
term.hideCursor();
term.grabInput();
}
Please let me know what am I doing wrong.
Thanks!