javascript - 右键单击 => 在 Angular 或 JS 中打印事件函数
问题描述
我想为所有类型的屏幕截图和打印编写函数。现在我想在 Angular 中编写右键单击和打印功能。如果有人知道破解,请告诉我。示例代码如下
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key == 'p') {
// console.log("tried to print")
// alert('This section is not allowed to print or export to PDF');
this.prtScrEvent("Screenshot");
}
});
//prtsc key press
window.addEventListener("keyup", (e) => {
if (e.keyCode == 44) {
// console.log("printing tried");
// alert("The 'print screen' key is pressed");
this.prtScrEvent("Screenshot");
}
});
async prtScrEvent(status) {....}
解决方案
看看这是否有助于右键单击。
document.addEventListener('contextmenu', (e) =>{
// Your code
})
推荐阅读
- amazon-web-services - AWS IOT - 列出事物 Cognito 用户特定
- wordpress - ACF 使用自定义前端表单在 Ajax 中保存和更新字段
- c# - 在 wcf 中创建 json 结构(json 的动态键)
- excel - 如何将值均匀地分布在多个单元格上但在最大限制下?
- php - 在html中获取最高值的参数
- python-2.7 - 从熊猫数据框保存不带双引号的csv文件
- qt - 用于 3D 图形的 QOpenGLFrameBufferObject
- vba - 宏来计算一个表中的行并在第二个表中添加 # 行
- apache-kafka - 来自kafka的元数据信息
- vb6 - 是否可以在 vb6 中从 dll 本身中获取 dll 的文件名?