Skip to content

Instantly share code, notes, and snippets.

View Kyle-Muir's full-sized avatar

Kyle Muir Kyle-Muir

  • Auckland, New Zealand
View GitHub Profile
@cstephe
cstephe / backspacedirective
Last active March 9, 2021 02:15
Angular directive: prevent backspace from acting like the back button
.directive('backSpaceNotBackButton', [function(){
return {
restrict: 'A',
link: function(scope, element, attrs){
// This will stop backspace from acting like the back button
$(element).keydown(function (e) {
var elid = $(document.activeElement)
.filter(
"input:not([type], [readonly]),"+
"input[type=text]:not([readonly]), " +