Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Backspace/Enter -> PageUp/Down testi</title>
- <script>
- window.onload = () => {
- document.addEventListener('keydown', (e) => {
- if(e.key == 'Enter') {
- window.scrollBy(0, window.innerHeight);
- }
- if(e.key == 'Backspace') {
- window.scrollBy(0, -window.innerHeight);
- }
- if(e.key == 'ArrowDown') {
- document.dispatchEvent(new KeyboardEvent('keydown',{'key': 'Enter'}));
- }
- if(e.key == 'ArrowUp') {
- document.dispatchEvent(new KeyboardEvent('keydown',{'key': 'Backspace'}));
- }
- });
- const listaElementti = document.getElementById('lista');
- for(let i=1; i<=100; i++) {
- const uusiElementti = document.createElement('li');
- uusiElementti.innerHTML = 'Listaelementti '+i;
- listaElementti.appendChild(uusiElementti);
- }
- };
- </script>
- </head>
- <body>
- <h1>Backspace/Enter -> PageUp/Down testi</h1>
- <p>Backspace / ArrowUp vierittää sivun verran ylös</p>
- <p>Enter / ArrowDown vierittää sivun verran alas</p>
- <ul id="lista"></ul>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment