Legacy keypress Event Listener Demo

Legacy event: This page demonstrates keypress only because older plus2net code used it. New code should normally use keydown or input.

JavaScript

const source = document.getElementById('t1');
const output = document.getElementById('t2');

source.addEventListener('keypress', () => {
  output.value = source.value;
});

Replace 'keypress' with 'input' when the real requirement is to copy the current text after any edit.

Event Handling · getElementById() · First legacy demo · keypress tutorial · Mouseover