<script type="text/javascript">
$(document).ready(function () {
var editor = CKEDITOR.replace('CKEditor1');
var ckeditor = CKEDITOR.instances['CKEditor1'];
ckeditor.on('key', function (event) {
var x = event.data.keyCode;
console.log(x);
if (x == 13) {
Capitalize();
}
else if (x == 32) {
alert("Press enter!!!!");
}
function Capitalize() {
if (this.value.match(/^[a-z]/)) {
this.value = this.value.replace(/^./, function (letter) {
return letter.toUpperCase();
});
}
}
});
});
按Enter键或空格键后,我想自动将首字母大写。我只是想在用户按下特定键时激活我的功能。