I\'m wrapping the selected text in span tags, when you click a button. If I then select a different piece of text and click the button, that text also gets wrapped in tags.
If you are looking to use the keyboard to bold characters, you can use the following (Mac):
$(window).keydown(function(e) {
if (e.keyCode >= 65 && e.keyCode <= 90) {
var char = (e.metaKey ? '⌘-' : '') + String.fromCharCode(e.keyCode)
if(char =='⌘-B') {
document.execCommand('bold')
}
}
})
Using keyboard to bold character: