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

  • Home
  • SEARCH
  • 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 9129819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:50:06+00:00 2026-06-17T07:50:06+00:00

As you can see in my fiddle . Or in my code bellow, I’m

  • 0

As you can see in my fiddle. Or in my code bellow, I’m trying to get an event to happen. When hovering over the box, and clicking the space bar, the confirmation window will apear. Once clicked yes, the box will delete.

The bug/problem being that once you delete the box and click the space bar again, it comes up with the same prompt. I thought I had solved this by turning off the listening with the rTwo.setListening(false);
layer.drawHit();

Anyways, any help would be appreciated. Thanks.

Code:

var stage = new Kinetic.Stage({
    container: 'container',
    width: 850,
    height: 400
});
var layer = new Kinetic.Layer();
var rTwo = new Kinetic.Rect({
    x: 0,
    y: 0,
    width: 100,
    height: 50,
    fill: 'blue',
    draggable: true,
});
layer.add(rTwo);
rTwo.on('mouseover', function() {
    document.onkeypress = function(e) {
        e = e || window.event;
        var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
        if (charCode == 32) {
            var b1 = confirm("Would you like to delete router 2?");
            if (b1 == true) {
                rTwo.hide();
                rLayer.draw();
                rTwo.setListening(false);
                rlayer.drawHit();
            } else if (b1 == false) {
                rLayer.draw();
            }
        }
    };
});
stage.add(layer);
  • 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-17T07:50:07+00:00Added an answer on June 17, 2026 at 7:50 am

    http://jsfiddle.net/gSEeb/4/

    So here is your logic: on mouseover you register the onkeypress function, which checks for key press and if that key is the spacebar, then show a prompt.

    mouseover-> register function

    function -> check key press -> is spacebar? -> show prompt

    if you look at this, you check for spacebar whether you are mouseover or not, as mouseover is only registering a function. Basically you need to re-check if your mouse is in the rectangle.

     rTwo.on('mouseover mousemove', function(){
          document.onkeypress = function(e) { 
               e = e || window.event;
               var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
               if (charCode == 32 && rTwo.intersects(stage.getUserPosition())) {
                    var b1 = confirm("Would you like to delete router 2?");
                    if (b1 == true){
                         rTwo.hide();
                         layer.drawHit();  // or whichever layer rTwo is in
                         layer.draw();
                         rTwo.setListening(false);
                    }
                    else if (b1 == false){
                         layer.draw();  // you don't really need to redraw this here as nothing is changed
                    }
               }
          };
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a dripping paint effect using d3.js see fiddle and relevant code: .append(line)
Here is the exact copy of my code: jsFiddleCode As you can see I
Please see the fiddle below to see the code and result: http://jsfiddle.net/jhacks/nnZWB/7/ I am
On this fiddle http://jsfiddle.net/mjmitche/qVdEy/6/ , you can see that the alignment of the text
I am trying to fiddle around with Zend_Cache, so I added following code to
I have a jsfiddle here http://jsfiddle.net/cbyJD/76 As you can see in the fiddle there
I can see the Graphical Layout of the XML file within the /res/layout folder,
I can see it looks like an alias for an unsigned int pointer, right?
I can see where svn:keywords like Id, LastChangedDate and Author are used and replaced
I can see how to change the fonts and colors in the IDE. Is

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.