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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:56:51+00:00 2026-05-23T00:56:51+00:00

I am creating a music player which uses the spacebar to pause and play

  • 0

I am creating a music player which uses the spacebar to pause and play audio, now is it possible to know if someone is currently typing in a textfield, because right now, if this user types in a textfield and audio is playing, when the user presses space the audio pauses, I would like basically that when the user is not in a textfield that a user can just play and pause audio, but when the user is typing that this function is disabled so the audio keeps playing. The code below, is the code I’m am current using for detecting when space is pressed;

//IF Space bar is Pressed
$(window).keypress(function(e) {
if(e.keyCode == 32) {
    if(document.getElementById('audio').paused){
        if(document.getElementById('video').style.display=="block"){

        }
        else{
            document.getElementById('audio').play();
            document.getElementById('pause').style.display="block"; 
            document.getElementById('play').style.display="none";
        }
    }
    else{
        if(document.getElementById('video').style.display=="block"){

        }
        else{
            document.getElementById('audio').pause();
            document.getElementById('pause').style.display="none";
            document.getElementById('play').style.display="block";
        }
    }
}
});
//END IF Space bar is pressed
  • 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-23T00:56:52+00:00Added an answer on May 23, 2026 at 12:56 am

    Check the event sources tagName attribute:

    function(e) {
     e = e || event;
     var el = e.srcElement || e.target,
         cando = !(/textarea|input/i.test(el.tagName));
    
     if(cando && e.keyCode == 32)  {
       /etc.
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating player application, which is playing audio streams through internet. I want
I was thinking of creating a music player with waveform like in zippyshare like
I'm creating a old school music emulator for the old GWBasic PLAY command. To
I am creating a little JavaScript music player that sits on the btottom of
I'm busy creating a mp3 player (for a music store). Everything works perfectly. Some
I am creating a music player application and it need that 2 actions to
I am creating a music application in which I am adding a scrollview to
I'm creating an online music player using php and javascript and I can't figure
long time reader, first time asker... I am making a music app which uses
I am creating a school project of music player and already created the GUI.

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.