Why does Windows sometimes "copy to clipboard" when I press the delete key?

47

7

Possible Duplicate:
How can I prevent shift-delete from cutting in Windows?

I'm a programmer so I spend a lot of time in a text editor. For whatever reason about 25% of the time when I press the Delete key Windows will copy my selection to the clipboard right before deleting.

It's frustrating because I'll highlight some code that I want to move, press Ctrl+X and then highlight the extra space left behind and press Delete. A moment later I'll hit paste but instead of seeing what I copied I'll get a blank line (the content of what I deleted).

Jeremy

Posted 2012-05-24T12:35:14.097

Reputation: 616

Question was closed 2012-05-28T22:22:22.793

For those that saw my original post--I cleaned up the title and the description to remove irrelevant info. – Jeremy – 2012-05-24T16:26:55.417

2as a side note, installing ClipX means you don't have to worry about losing the data on your clipboard (downside: can't live without it now!) – Simon – 2012-05-24T16:58:35.593

After Oliver pointed out the underlying cause of the problem I looked around for a permanent solution. I posted my findings as an "Answer" below. – Jeremy – 2012-05-24T19:31:29.457

There's one work around if you use Visual Studio: use Ctrl+Shift+V to browse the clipboard history. – Laurent Couvidou – 2012-05-24T21:28:16.677

If you're losing what was in your clipboard buffer, a handy little tool to download (assuming you're on windows) is a tool called ClipX (http://bluemars.org/clipx/)

– Roy Rico – 2012-05-24T23:12:50.497

Am I old if this is my primary way of copy&pasting? – Doug T. – 2012-05-26T00:03:04.317

Answers

79

Solutions to this can either be found in this question:
How do I remap Shift + Del on Windows to mean Delete instead of Cut? or in Jeremy's own answer.

You're most likely pressing Shift+Del.

You still have Shift pressed from making your selection. Shift+Del is the key combination to Cut (just like Ctrl+X).

Der Hochstapler

Posted 2012-05-24T12:35:14.097

Reputation: 77 228

7This can be extremely frustrating when cleaning up whitespace before pasting that special piece of code from your clipboard. Happens to me all the time, drives me crazy. – Der Hochstapler – 2012-05-24T13:19:53.980

9Thank you so much--you just solved my problem! I'm a little embarrassed that I was unaware of this keyboard combination though. I've always known about shift + insert but somehow never heard of shift + del (makes sense though). Thanks again! – Jeremy – 2012-05-24T13:20:07.753

@Jeremy - I didn't know about it either. Thanks Oliver. :-) – Anonymous – 2012-05-24T13:24:12.190

This is among my most-hated shortcuts, so I turn off the copying whenever possible. :) – user541686 – 2012-05-24T13:33:02.783

8Just some additional information, this is a key combination for left handed users, so they can use it while holding the mouse (like right handed users can with Ctrl+C etc.) – Holger – 2012-05-24T14:52:47.357

@Holger: Wow, that makes a lot of sense and I have never thought about that. Do you maybe have a piece of reference on this? – Der Hochstapler – 2012-05-24T14:54:20.883

1@OliverSalzburg Sorry don't have one and couldn't find it. But I've heard it from a left handed person – Holger – 2012-05-24T15:05:41.197

@Mehrdad - Curious, how do you turn off copying? – Jeremy – 2012-05-24T15:12:25.180

3@Jeremy: I've seen it in Visual Studio -- I just go to the Keyboard shortcuts page, find the Shift+Delete entry, and instead of mapping it to Cut, I map it to LineDelete (or whatever it was called). Then it actually does something useful. :) – user541686 – 2012-05-24T15:14:48.950

@OliverSalzburg: That's pretty amazing, I wish it was documented somewhere so I could turn off these left-handed features haha. xD Cool! – user541686 – 2012-05-24T15:15:58.230

2

@Holger: Found something. They seem to come from IBM CUA. Not sure if their intention was to ease access for left-handed users. But it works nevertheless :)

– Der Hochstapler – 2012-05-24T15:20:51.160

@Mehrdad - Ahh, I did see that in Visual Studio as I was researching how to fix this. Since then I've found a system-wide solution for this and even created a mini tutorial on how to set it up but I'm not allowed to post it (as an "answer") because I'm a new user with a low reputation score. Apparently I'll be able to post it later today. – Jeremy – 2012-05-24T15:25:38.440

@Jeremy: Oh cool! Is it with AutoHotkey by any chance? (And yeah I hope you get lots of upvotes!) – user541686 – 2012-05-24T15:26:35.843

@Mehrad: yes, it's with AutoHotkey. At first I was hesitant to try it but it was pretty easy to setup and it worked perfectly on the first try. Yay--finally free of this annoying "feature"! The one thing that I don't understand is why this started when I switched to Windows 7 (from XP). Oh well, I'm just relieved that it's fixed. – Jeremy – 2012-05-24T15:59:26.433

2@Oliver: If you're deleting whitespace by selecting it first, then it shouldn't make a difference if you use delete or backspace. So just use backspace and you won't accidentally overwrite your selection. Shift+Backspace should be the same as just hitting Backspace. – Lèse majesté – 2012-05-24T16:55:09.797

That a bit counter-intuitive. I'm used to pressing Shift+Del to delete files on Windows without moving to the Recycle Bin. Shift+Del with selected text deletes the text and DOES save it to the Recycle Bin (aka clipboard). – jacobsee – 2012-05-24T16:55:36.860

Anybody know if this is configurable in the Registry? – Vimes – 2012-05-24T17:43:42.213

1Per the CUA point by Oliver above - I am thinking that the key combo comes from the distant murky past, where control keys may not have been on the keyboard. It is how you delete files in the Mac finder and songs in iTunes. So its not just a 'winders' thing. – Rawheiser – 2012-05-24T17:53:59.823

1I remember first learning about Shift+Del, Shift+Ins when I was using a Microsoft, DOS based, full screen editor to develop code in the early 1990s. Back then, Ctrl+C was for interrupting a program (and still is in *nix land), and Windows 3.0 was the newest shiny toy M$ was offering. – jwernerny – 2012-05-24T19:12:06.687

After Oliver pointed out the underlying cause of the problem I looked around for a permanent solution. I've posted my findings as an "Answer" below. – Jeremy – 2012-05-24T19:32:44.713

Shift - DEL - that's from the old days. – Preet Sangha – 2012-05-25T02:43:33.587

I find it extremely annoying that Windows uses ctrl-c/ctrl-x for copying/cutting. That's the keys I want to use in console applications. ctrl-del and so on for clipboard tasks is very useful as it is close to the arrow keys and my hand is pretty much in that area when I selected text. (Also, I use my mouse with the left hand.) – Andrew J. Brehm – 2012-05-25T07:20:33.170

1@Lèsemajesté: Consider converting your comment on Backspace to an answer. – krlmlr – 2012-05-25T07:56:13.183

1

Related: http://superuser.com/questions/235842/how-do-i-remap-shift-del-on-windows-to-mean-delete-instead-of-cut. Also mentions AutoHotKey.

– krlmlr – 2012-05-25T07:56:25.320

7

* SOLUTION *

After Oliver pointed out that shift+delete is a keyboard shortcut for Cut (just like Ctrl+x) I started looking for a way to turn this "feature" off.

The only solution I've found is to use AutoHotKey (free). Here's some basic setup instructions for anyone else that's interested:

First, install AutoHotKey, run it and allow it to create (and open) the example/default AutoHotkey.ahk script when it prompts you. Add the following to the script:

+Delete::
    KeyWait, Shift
    Send, {Delete}
    return

I'm not sure but you may have to "reload" the script before it starts working (I reloaded before testing). To reload, bring the AutoHotKey app to the foreground and press Ctrl+R (or click File -> Reload Script).

If you're happy with the results then you'll probably want to setup AutoHotKey to run automatically on startup. This is done by selecting the AutoHotkey.ahk file (in your 'My Documents' folder) and then going to your startup folder (C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) and clicking "Paste Shortcut" from the "Edit" menu (Press Alt+E if you don't see an menu bar).

In testing, this fix worked great for me on Windows 7. Thanks to Oliver for identifying the underlying problem! :-)

Jeremy

Posted 2012-05-24T12:35:14.097

Reputation: 616

8You know, you could just learn to type properly as well ;P – Svish – 2012-05-24T20:12:45.563

+1 Svish. And there is no reason to quote "feature". Using ctrl-c for copying in some programs (those using windows) and canceling tasks in others (those running in a console window) is a "feature". But using different key combinations for different tasks is a feature. – Andrew J. Brehm – 2012-05-25T07:22:09.703

Also, what do you do on machines that do not have AutoHotKey installed, be it in a library or in a web café? – krlmlr – 2012-05-25T07:57:30.327

There actually was a question like that. user946850 found it. Cheers.

– Der Hochstapler – 2012-05-25T09:54:55.140

2

Another possibility is a Sticky Key accessibility feature in Windows 7, so you pressed Shift key before and when you press Del, Sticky Key combines them to Shift+Del, which is another shortcut for Cut (to the buffer).

I found following article helpful in figuring out the setting - Stuck shift keys - windows 7 64 bit.

artdanil

Posted 2012-05-24T12:35:14.097

Reputation: 131

0

Is this happening on both of your Win7 boxes? If it's only one, I'd tend to think perhaps a problem with your keyboard as the C and X keys are side by side. Perhaps the C key partially sticking and getting depressed slightly when you press the X key. The only other time I've seen this happen is when my finger doesn't go to the key my brain tells it too. :) I have a half dozen Win7 machines and I've never seen this happen except when I could attribute it to either the keyboard or my fat finger.

BBlake

Posted 2012-05-24T12:35:14.097

Reputation: 5 120

That's what was strange to me--it was happening on two computers. I'd have tried swapping keyboards if it was just one computer. It turns out that Oliver was right. I may have to find a tool that allows me to disable the shift + del keyboard combination. Thanks for sharing your thoughts. :-) – Jeremy – 2012-05-24T13:23:42.977

0

Since the underlying cause is due to the Shift+Del shortcut, another solution would be to use Backspace to delete highlighted text rather than Del.

Even though Del and Backspace normally perform different actions (at least on PCs), they can both be used to delete a selection. And there's no risk of overwriting your clipboard, since Shift+Backspace is the same as Backspace.

Lèse majesté

Posted 2012-05-24T12:35:14.097

Reputation: 3 129