term.js
term.js copied to clipboard
Different behaviour for Cmd+C, Cmd+v, etc on Mac
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.
+1 Copy and paste doesn't work for Macs, at least in the way that everyone tries. No one will try Opt-C/V!
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.
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
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.
Yeah, the mode key event attributes in mac are very non-intuitive.
@petethepig thanks for your patch, works great.
@chjj would be nice to have this or something to its effect
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.
I tried to support Cmd-C, Cmd-V on Mac using hidden textarea. https://github.com/chjj/term.js/pull/97