
No License
JavaScript
2022年02月18日
window.addEventListener('keypress', handleKeyDown);
var pressed = "";
var howmany = 0;
document.querySelector('#main').innerHTML = `
<h1>${pressed}<h1>
<h2>現在${howmany}文字入力中です<h2>
<h3>右クリックでファイルにセーブできます<h3>
`
function handleKeyDown (event) {
if(event.key !== "Enter"){
if(event.key === "Backspace"){
pressed = pressed.slice(0, pressed.length - 1)
}else if (event.key === " "){
pressed += " "
}else if(/[a-zA-Z0-9]/.test(event.key)){
pressed += event.key
}else if(/[,.;:@!"#$%&'-^<>?+*`~=_/]/.test(event.key)){
pressed += event.key
}
}
howmany = pressed.length
document.querySelector('#main').innerHTML = `
<h1>${pressed}<h1>
<h2>現在${howmany}文字入力中です<h2>
`
}
function draw() {
if (mouseButton === RIGHT && mouseIsPressed === true) {
var typed = createWriter('typed.txt')
typed.print(pressed);
typed.close();
typed.clear();
}
}
No one still commented. Please first comment.
Output