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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:48:55+00:00 2026-05-27T05:48:55+00:00

I have this CSS3 enter button here : If you click it, it seems

  • 0

I have this CSS3 enter button
here:

If you click it, it seems like it’s pressed. I want to achieve the same effect (probably using jQuery), by pressing the enter key physically on my keyboard.

I did something like this: (sorry if it’s completely wrong, I don’t do jQuery at all)

<script type="text/javascript">
   $(document).ready(function(){
     $("enter").keypress(function(event){
       if(event.keyCode == 13){
         $(this).toggleClass(".button-clicked");
       }
     });
   });
</script>

The CSS selector for the unpressed button is:
.button and .button.orange {}

The CSS selector for the pressed button is:
.button:active, .button-clicked {}

Thanks for your help!

  • 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-27T05:48:55+00:00Added an answer on May 27, 2026 at 5:48 am

    I haven’t tested this, but I think you should be able to do something like

    I have just tested this (and linked to a demo, below the jQuery), and it works pretty well:

    $('body').keydown(
        function(e){
            if (e.which == 13) { // enter
                $('buttonSelector').addClass('button-clicked');
            }
        }).keyup(
        function(e){
            if (e.which == 13) { // enter
                $('buttonSelector').removeClass('button-clicked');
            }
        });
    

    JS Fiddle demo.

    With this the keydown causes the button to appear pressed so long as the enter key is pressed, and, on release, triggers the keyup() handler, changing the style of the button so as to appear un-clicked.

    Refined the above, somewhat, using on(), though having to use an if/else if statement to check the function type:

    $('body').on('keydown keyup', function(e) {
        if (e.type == 'keydown') {
            if (e.which == 13) { // enter
                $('#button').addClass('button-clicked');
            }
        }
        else if (e.type == 'keyup') {
            if (e.which == 13) { // enter
                $('#button').removeClass('button-clicked');
            }
        }
    });
    

    JS Fiddle demo.

    References:

    • keydown().
    • keyup().
    • addClass().
    • removeClass().
    • on().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSS3 button like this <button class="button brownb">My Button</button> CSS .brownb:active {
I have come across this website: http://www.fetchak.com/ie-css3/ It seems to work when I enter
I want to make a jquery version of this css3 effect so that it
Is it possible to have the same text effect (inner shadow, shade) as this
I have a simple css3 button and I need to align this button inside
I have this code in jQuery, that I want to reimplement with the prototype
I have found this article: http://www.zurb.com/article/221/css3-animation-will-rock-your-world on css3 animations. I am trying to create
I have this navigation bar with a rollover using css3 animation. It functions great
Is it possible to use CSS/CSS3 to mirror text? Specifically, I have this scissors
I have this jQuery: $('.infoExpand p').hide(); $('.infoData').click(function(){ $('.infoData').removeClass('infoDataHov'); $(this).addClass('infoDataHov'); var id = this.id; id

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.