Here's a snippet which automatically selects a cell just before copy, though it works with CTRL+C only.
window.onload = function () {
var selected,
selectCell = function (e) {
var cell = e.target,
range, selection;
if (cell.tagName.toLowerCase() !== 'td') {
while (cell = cell.parentElement) {
if (cell.tagName.toLowerCase() === 'td') {
break;
}
}
}
if (!cell || cell.tagName.toLowerCase() !== 'td') {
return;
}
if (selected) {
selected.style.backgroundColor = '';
}
cell.style.backgroundColor = '#ff0';
selected = cell;
},
beforeCopyCell = function (e) {
var range, selection;
if (!selected || !e.ctrlKey || e.which !== 67) {
return;
}
selected.focus();
selection = window.getSelection();
selection.removeAllRanges();
range = document.createRange();
range.selectNode(selected);
selection.addRange(range);
},
afterCopyCell = function (e) {
if (!selected || !e.ctrlKey || e.which !== 67) {
return;
}
selection = window.getSelection();
selection.removeAllRanges();
},
table = document.getElementById('table');
table.addEventListener('click', selectCell);
table.addEventListener('keydown', beforeCopyCell);
document.body.addEventListener('keyup', afterCopyCell);
};
The code seems to work well in FF25, Chrome31 and IE11, but it's not working in IE<9.
A live demo at jsFiddle. (The fiddle demonstrates an alternative code, which doesn't work well with IE.)
Another demo, which somehow implements also copying the cell via contextmenu. This works in FF26, Chrome31 and IE11 only, though if omitting/rebuilding the class toggling of the selected cell, the code is supposed to be IE9+ combatible.