Pisze krótki kod, który ma za zadanie oczekiwać na zdarzenie klawiatury (Naciśnięcie klawisza enter) oraz wywołanie funkcji
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" name="" id="text" value="">
<script src="main.js">
</script>
</body>
</html>
const p = document.querySelector('#demo');
const input = document.querySelector('#text');
let inputValue = 'Wartość';
input.addEventListener('keydown', e =>{
if(e.keycode === 13)
{
input.value = inputValue;
console.log(e.keycode);
}
});
inputValue = input.value;
W ten sposób też próbowałem