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 330881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:43:22+00:00 2026-05-12T09:43:22+00:00

I have an input (outside form) that captures name of an image. User should

  • 0

I have an input (outside form) that captures name of an image. User should fill in a new name and hit enter. Ajax callback renames the image. This works.

I’d like to add ability to ‘reset’ the input content when the user presses escape (#27). But I’m not able to fill the value of the input with my value.

The code is

<input id="escapeInput" value="this is test" /> <input type="button" id="setDetaultToEscapeInput" value="Set default" />

jQuery(document).ready(function() {
    jQuery("#escapeInput").keydown(function(evt) {
        if (evt.keyCode == 27) {
            var input = jQuery(this);
            input.val('some default value') // doesn't work
            input[0].value = 'some default value 2'; // doesn't work
            input.parent().append('changed');
        }
    });
    jQuery("#setDetaultToEscapeInput").click(function() {
        var input = jQuery("#escapeInput");
        input.val('some default value') // works ok
    });
});

The interesting thing is that if I test e.g. for ‘A’ character ( if (evt.keyCode == 65)), the code works.
Any idea how to handle it? It doesn’t work only in FF (Opera and IE8 are OK).

  • 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-12T09:43:22+00:00Added an answer on May 12, 2026 at 9:43 am

    Try using the keyup event instead.

    $(function() {
        $("#escapeInput").keyup(function(e) {
            if (e.keyCode == 27) {
                $(this).val("some default value");
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input form with two textareas allowing a user to type in
I have a form. Outside that form, I have a button. A simple button,
I have a form and it has 4 input elements. if the user enters
Say I have: <form method=get action=something.php> <input type=text name=name /> </form> <input type=submit />
So I have a script that makes dynamic form content and each input has
I have an HTML form as follow: <form method=POST action=http://> Username: <input type=text name=username
I have input fields, which I process with AJAX and send it on another
I have an input box <input type=text name=search id=search /> <img src=icon.png alt= id=doSearch
I have a form select replacement that uses jQuery to show options in a
I have a text box input in a form; when I click it, a

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.