Click me
Document
Document 搜索
Document
Document
上下文菜单
- Java
- JavaScript
- Python
- AI
<input type="text" id="txtUserName" />
</form>
<script>
const oUserName = document.querySelector('#txtUserName')
// oUserName.addEventListener('keypress',(e) => {
// console.log(`charCode:${String.fromCharCode(e.charCode)}`)
// console.log(`keypress: ${e.key}`)
// })
// oUserName.addEventListener('keydown',(e) => {
// console.log(`keyCode: ${e.keyCode}`)
// console.log(`keydown: ${e.key}`)
// })
oUserName.addEventListener('keypress',(e)=> {
console.log('keypress')
});
oUserName.addEventListener('keydown',(e)=> {
console.log('keydown')
});
oUserName.addEventListener('keyup',(e)=> {
console.log('keyup')
})
oUserName.addEventListener('input',(e)=> {
console.log('input')
})
</script>
test
在这里右键单击或者按 Ctrl+click 会出现一个自定义的上下文菜单。 点其他地方就是默认的上下文菜单。