Skip to content

Different behaviour for Cmd+C, Cmd+v, etc on Mac#7

Open
petethepig wants to merge 1 commit into
chjj:masterfrom
petethepig:master
Open

Different behaviour for Cmd+C, Cmd+v, etc on Mac#7
petethepig wants to merge 1 commit into
chjj:masterfrom
petethepig:master

Conversation

@petethepig

Copy link
Copy Markdown

It allows you to copy/paste any text from/into the terminal.
I suggest it, since this is the default behaviour in Terminal.app on Mac.

@jagill

jagill commented Feb 7, 2014

Copy link
Copy Markdown

+1
Copy and paste doesn't work for Macs, at least in the way that everyone tries. No one will try Opt-C/V!

@chjj

chjj commented Feb 7, 2014

Copy link
Copy Markdown
Owner

Now I'm confused. The isMac and ev.metaKey check is there to check for a mac's equivalent of Alt (which is Option, I think?). Why would that if statement affect the Command key? This change would also stop a whole range of key combinations from working.

Could either of you show me the raw event output for keydown of Cmd+[anything] in the browser? It should be event.ctrlKey.

@jagill

jagill commented Feb 7, 2014

Copy link
Copy Markdown

The check for Cmd in mac is event.metaKey. Option is event.altKey. Ctrl is event.ctrlKey.

Here is Cmd-C:

jQuery.Event {originalEvent: KeyboardEvent, type: "keydown", isDefaultPrevented: function, timeStamp: 1391791240401, jQuery182012300834944471717: true…}
altKey: false
attrChange: undefined
attrName: undefined
bubbles: true
cancelable: true
char: undefined
charCode: 0
ctrlKey: false
currentTarget: Window
data: null
delegateTarget: Window
eventPhase: 3
handleObj: Object
isDefaultPrevented: function returnFalse() { // 3279
jQuery182012300834944471717: true
key: undefined
keyCode: 67
metaKey: true
originalEvent: KeyboardEvent
relatedNode: undefined
relatedTarget: undefined
shiftKey: false
srcElement: textarea.ace_text-input
target: textarea.ace_text-input
timeStamp: 1391791240401
type: "keydown"
view: Window
which: 67

Here is Opt-C:

jQuery.Event {originalEvent: KeyboardEvent, type: "keydown", isDefaultPrevented: function, timeStamp: 1391791248160, jQuery182012300834944471717: true…}
altKey: true
attrChange: undefined
attrName: undefined
bubbles: true
cancelable: true
char: undefined
charCode: 0
ctrlKey: false
currentTarget: Window
data: null
delegateTarget: Window
eventPhase: 3
handleObj: Object
isDefaultPrevented: function returnFalse() { // 3279
jQuery182012300834944471717: true
key: undefined
keyCode: 229
metaKey: false
originalEvent: KeyboardEvent
relatedNode: undefined
relatedTarget: undefined
shiftKey: false
srcElement: textarea.ace_text-input
target: textarea.ace_text-input
timeStamp: 1391791248160
type: "keydown"
view: Window
which: 229

Here is Ctrl-C:

jQuery.Event {originalEvent: KeyboardEvent, type: "keydown", isDefaultPrevented: function, timeStamp: 1391791364750, jQuery182012300834944471717: true…}
altKey: false
attrChange: undefined
attrName: undefined
bubbles: true
cancelable: true
char: undefined
charCode: 0
ctrlKey: true
currentTarget: Window
data: null
delegateTarget: Window
eventPhase: 3
handleObj: Object
isDefaultPrevented: function returnFalse() { // 3279
jQuery182012300834944471717: true
key: undefined
keyCode: 67
metaKey: false
originalEvent: KeyboardEvent
relatedNode: undefined
relatedTarget: undefined
shiftKey: false
srcElement: textarea.ace_text-input
target: textarea.ace_text-input
timeStamp: 1391791364750
type: "keydown"
view: Window
which: 67

@chjj

chjj commented Feb 7, 2014

Copy link
Copy Markdown
Owner

Ah, okay. So command is considered meta (seriously unfamiliar with mac keyboards). Gotcha. Yeah, I'll add a better check that won't disrupt any other key combinations either. Thanks for checking.

@jagill

jagill commented Feb 7, 2014

Copy link
Copy Markdown

Yeah, the mode key event attributes in mac are very non-intuitive.

@soumith

soumith commented Apr 27, 2014

Copy link
Copy Markdown

@petethepig thanks for your patch, works great.

@jessetane

Copy link
Copy Markdown
Contributor

@chjj would be nice to have this or something to its effect

@takluyver

Copy link
Copy Markdown

See also PR #37. I'm not a Mac user, but assuming that Option+key on Mac should work like Alt+key on other systems, I think that one is preferable - this one appears to disable all Alt shortcuts on Macs.

@yoshiokatsuneo

Copy link
Copy Markdown

I tried to support Cmd-C, Cmd-V on Mac using hidden textarea.
#97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants