Enhance user experience and bolster security in your web applications using the Web Interaction Control Toolkit. This toolkit provides easy-to-use JavaScript snippets that address various aspects of user interaction, preventing unwanted actions and ensuring a seamless and secure browsing experience.
Disable the context menu when right-clicking on the page to promote a controlled user interface.
$(document).on("contextmenu", function () {
return false;
});
Prevent text selection across the entire page while selectively enabling it for input and textarea elements.
$("body").css({
"-webkit-user-select": "none",
"-moz-user-select": "none",
"-ms-user-select": "none",
"user-select": "none",
});
$("input, textarea").css({
"-webkit-user-select": "auto",
"-moz-user-select": "auto",
"-ms-user-select": "auto",
"user-select": "auto",
});
Disable specific keyboard shortcuts to maintain control over search and view source functionalities.
$(document).on("keydown", function (event) {
if ((event.ctrlKey || event.metaKey) && (event.keyCode === 70 || event.keyCode === 85)) {
event.preventDefault();
}
});
Secure your content by disabling copying via right-click and keyboard shortcuts.
document.addEventListener("keydown", function (event) {
if ((event.ctrlKey || event.metaKey) && (event.keyCode === 67 || event.keyCode === 77)) {
event.preventDefault();
}
});
document.addEventListener("keydown", function (event) {
if ((event.ctrlKey || event.metaKey) && event.shiftKey && (event.code === "KeyC" || event.code === "KeyM")) {
event.preventDefault();
event.stopPropagation();
}
});
- Copy the desired snippet from the toolkit.
- Integrate the snippet into your project's JavaScript file or script tag.
<script src="your-script.js"></script>
- Customize the snippets as needed for your application.
If you have suggestions, improvements, or encounter issues, feel free to contribute by opening issues or submitting pull requests. Together, let's build a more secure and user-friendly web!
This toolkit is licensed under the MIT License.