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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:33:05+00:00 2026-06-12T13:33:05+00:00

If the user types someting in the textarea#q, the do_domething() function is called. If

  • 0

If the user types someting in the textarea#q, the do_domething() function is called. If the user pastes the text instead of typing it, the do_something() function should be avoided. Any ideas? This is my current code:

$('#q').keyup(function(e){
    do_something();
}).bind('paste',function(event) {
    //user pasted text, there is not need to do_something();
    //tried both of these approaches, none worked out.
    event.stopPropagation();
    event.stopImmediatePropagation();
});
  • 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-06-12T13:33:06+00:00Added an answer on June 12, 2026 at 1:33 pm

    If a user right clicks and uses the context menu to paste into the textarea then you are good. That leaves the issue of the user using “Ctrl + P” to paste into the textarea. You could try capturing the keycodes and skipping the function when the key combo is pressed. Try this:

    On keydown:
    
    var isCtrl = false;
    
    $('#q').keydown(function (event) {
        if(e.keycode == 17)
            isCtrl = true;
        if(isCtrl == false)
            do_something();
    });
    
    $('#q').keyup(function (e) {
        isCtrl = false;
    });
    

    So the idea is to capture the “Ctrl” key. If they press it you don’t want to fire the function. In order to paste “Ctrl + P”, the “Ctrl” key must be pressed therefore “isCtrl” would be true preventing the firing of the do_something(); function. The only exception to this would be using sticky keys in windows where “Ctrl” doesn’t have to be held when you type “p”.

    This all is assuming of course that it is alright if you fire your function in the keydown event rather than in the keyup. Depending on your function this may not be appropriate.

    Hope this works.

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

Sidebar

Related Questions

A user types any text in the textarea on html page. The string is
I am trying to implement a text box that, when the user types something,
if a user types in an input say 3 into a text box three
If a user types in [[0,0,0], [0,0,1], [1,1,0]] and press enter, the program should
I want that whenever the user types http://localhost:8280/services/Facebook/sea the actual request should be http://localhost:8280/services/Facebook/search?q=jack
I have a <textarea> that a user types something in, and they are allowed
Hi im updating my page using jQuery/javascript once a user types something. <script type=text/javascript>
I get a textarea with a keyup function attached. When the user type something,
I get a textarea with a keyup function attached. When the user type something,
In MVC Pattern: when user types something, Control will translate user input to Model

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.