Users Pricing

forum

Home Forums Show image when key is pressed with jQuery – MindStick

Show image when key is pressed with jQuery

Anonymous User 2259 08 Apr 2013
Hi Mindstickians!

I'm trying to make a simple app that when a key is pressed on the users keyboard an image appears respective to that letter. I would like to do this for the entire alphabet (a, b, c...)

if a is pressed a.jpg shows up on my page, if r was pressed r.jpg would appear and so on.

I was going to do this with a mega list of if else statements only im sure there must be another way?

var ctrlPressed = false;
$(window).keydown(function(evt) {
  if (evt.which == 17) { // ctrl
    ctrlPressed = true;
      alert('sdf');
  }
})

Thanks in advance!

2 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md