Vanilla JS: Totally disabling a “save” functionality in webpages

前端 未结 4 1678
Happy的楠姐
Happy的楠姐 2021-01-23 23:54

Assume I\'m a junior Wikipedia user that just want to experiment with changing some wikipedian content with the Wiki text editor in an edit-page, but not saving my changes in an

4条回答
  •  既然无缘
    2021-01-24 00:19

    The keyCodes all represent modifier keys. The keypress event does not fire with these keys:

        document.addEventListener('keypress', function(e) {
        console.log('keypress worked');
        });
    
        document.addEventListener('keyup', function(e) {
        console.log('keyup worked');
        });

    Also, please note that .keyCode is deprecated. Should use .key

提交回复
热议问题