Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:34:48+00:00 2026-05-24T01:34:48+00:00

How can I move an element horizontally by 10pixels upon an arrow keydown event

  • 0

How can I move an element horizontally by 10pixels upon an arrow keydown event in JQuery? For instance I have

  <p class="move">This is to be moved</p>

I have tried the following code but it does not work..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQuery(2)</title>
<style type="text/css">
.Test1{width:100px;}
</style>
<script type="text/javascript"  src="jquery.js">  </script>
<script type="text/javascript">

$(document).ready(function() {


$('#target').keydown(function() {
  alert('Handler for .keydown() called.');
});

});
</script>

</head>

<body>


<div id="parent">
<p id="target">This is a text</p>
</div>
</body>
</html>

The above was supposed to alert me upon a keydown event but it does not..How can I fix this?In other words it does not capture my keydown event..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:34:49+00:00Added an answer on May 24, 2026 at 1:34 am

    In general? You could handle the keyDown event on its parent.

    For example:

    http://jsfiddle.net/NXEU4/1/

    Difficult to provide a more detailed answer without more information.

    EDIT

    Your code does not work because your browser does not allow the <p> to receive input focus, and hence will not have the keyDown event fire.

    The example I provided is shifting an absolutely positioned element. For your example, you could simply increase the margin-left style.

    EDIT2

    Oops, might want to update the link as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I move an element to the end of the body? Using jQuery,
How can I move an xml element elsewhere in a document? So I have
How can I use jQuery to move an element from: position: absolute; left: 169px;
I have this if(noDelay){ $(element).find(. + options.class).remove(); } else { $(element).find(. + options.class).fadeOut().remove(); }
How can I make a div element move up and down the page when
I can move my pointer up and down one line with my arrow key
In one of my iPhone projects, I have three views that you can move
Apparently I can't move files on different volumes using Directory.Move. I have read that
This is my first time using JQuery in any of my projects. I have
I have already the list pointer of CDrawObject* std::list<CDrawObject*> elements; How I can move

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.