所以我在搞 JS,我做了一些东西,当我按下一个键时,它会显示那个字母。所以如果我在键盘上按A,KeyA 会出现在页面上,但我想知道当我按A时是否可以显示图像。提前致谢 <3(我所拥有的也在代码片段中)
const log = document.getElementById('log');
document.addEventListener('keypress', logKey);
function logKey(e) {
log.textContent += ` ${e.code}`;
}
function logKey(a) {
log.textContent += ` ${a.code}`;
}
function logKey(a) {
log.textContent += ` ${a.code}`;
}
function logKey(q) {
log.textContent += ` ${q.code}`;
}
function logKey(w) {
log.textContent += ` ${w.code}`;
}
function logKey(r) {
log.textContent += ` ${r.code}`;
}
function logKey(t) {
log.textContent += ` ${t.code}`;
}
function logKey(y) {
log.textContent += ` ${y.code}`;
}
function logKey(u) {
log.textContent += ` ${u.code}`;
}
function logKey(i) {
log.textContent += ` ${i.code}`;
}
function logKey(o) {
log.textContent += ` ${o.code}`;
}
function logKey(p) {
log.textContent += ` ${p.code}`;
}
function logKey(s) {
log.textContent += ` ${s.code}`;
}
function logKey(d) {
log.textContent += ` ${d.code}`;
}
function logKey(f) {
log.textContent += ` ${f.code}`;
}
function logKey(g) {
log.textContent += ` ${g.code}`;
}
function logKey(h) {
log.textContent += ` ${h.code}`;
}
function logKey(j) {
log.textContent += ` ${j.code}`;
}
function logKey(k) {
log.textContent += ` ${k.code}`;
}
function logKey(l) {
log.textContent += ` ${l.code}`;
}
function logKey(z) {
log.textContent += ` ${z.code}`;
}
function logKey(x) {
log.textContent += ` ${x.code}`;
}
function logKey(c) {
log.textContent += ` ${c.code}`;
}
function logKey(v) {
log.textContent += ` ${v.code}`;
}
function logKey(b) {
log.textContent += ` ${b.code}`;
}
function logKey(n) {
log.textContent += ` ${n.code}`;
}
function logKey(m) {
log.textContent += ` ${m.code}`;
}
<p id="log"></p>
相关分类