(function(undefined){
    'use strict';
    var orignalMouseMove = L.Draw.Polyline.prototype._onMouseMove, currentMarker, straightline, 
        lastPoint, map, dragging;
    
    window.onkeydown = function(e){
        straightline = e.ctrlKey;
    };

    window.onkeyup = function(e){
        straightline = false;
    };

    L.Draw.Polyline.prototype._onMouseMove = function(e){
        orignalMouseMove.call(this, e);

        if(dragging) return;
        
        if((straightline) && currentMarker)
        {
            var currentPoint = map.latLngToLayerPoint(currentMarker.getLatLng());
            
            if(isHorizontal(e.latlng)){
                currentMarker.setLatLng(L.latLng(lastPoint.lat, currentMarker.getLatLng().lng));
                e.layerPoint.y = currentPoint.y;
            }
            else{
                currentMarker.setLatLng(L.latLng(currentMarker.getLatLng().lat, lastPoint.lng));
                e.layerPoint.x = currentPoint.x;
            }

            this._updateGuide(e.layerPoint);
            currentMarker.update();
        }
    };

    L.Map.prototype.initStraightLines = function(){
        map = this;
        map.on('dragstart', function(){
            dragging = true;
        });
        map.on('dragend', function(){
            dragging = false;
        });
        map.on('mouseup', function(e){
            
            setTimeout(function(){
                if(dragging) return;

                var currentLine = getLayerOfType(L.Polyline);
            
                currentMarker = getLayerOfType(L.Marker);
                
                if(currentMarker){
                    
                    if(straightline && currentLine){
                         
                        var latLngs = currentLine.getLatLngs();
                        
                        if(lastPoint && latLngs.length){
                            
                            if(isHorizontal(e.latlng)){
                                latLngs[latLngs.length - 1].lat = lastPoint.lat;
                                latLngs[latLngs.length - 2].lat = lastPoint.lat;
                            }
                            else {
                                latLngs[latLngs.length - 1].lng = lastPoint.lng;
                                latLngs[latLngs.length - 2].lng = lastPoint.lng;   
                            }
                            currentLine.redraw();
                            currentMarker.update();
                        }
                    }
                    
                    lastPoint = currentMarker.getLatLng();
                }    
            });            
        });
    };
    
    function getLayerOfType(type){
        var result;
        map.eachLayer(function(layer){
            if(layer instanceof type){
                result = layer;
            }
        });
        return result;
    }

    function isHorizontal(mousePosition){
        var latDiff = Math.abs(mousePosition.lat - lastPoint.lat);
        var lngDiff = Math.abs(mousePosition.lng - lastPoint.lng);

        return latDiff < lngDiff;
    }    
})();
@@ -421,32 +421,49 @@
 e);%0A%0A        if(
+!straightline %7C%7C 
 dragging) return
@@ -464,24 +464,25 @@
 return;%0A
+%0A
         
 %0A       
@@ -477,38 +477,65 @@
     
-%0A        if((straightline) && 
+var currentMarker = getLayerOfType(L.Marker);%0A        if(
 curr
@@ -584,37 +584,17 @@
 ntPo
-int = map.latLngToLayerPoint(
+sition = 
 curr
@@ -614,17 +614,16 @@
 LatLng()
-)
 ;%0A      
@@ -632,145 +632,125 @@
     
-%0A            if(isHorizontal(e.latlng))%7B%0A                currentMarker.setLatLng(L.latLng(lastPoint.lat, currentMarker.getLatLng().lng));
+var currentPoint = map.latLngToLayerPoint(currentPosition);%0A%0A            if(isHorizontal(e.latlng, currentPosition))%7B
 %0A   
@@ -831,105 +831,8 @@
 se%7B%0A
-                currentMarker.setLatLng(L.latLng(currentMarker.getLatLng().lat, lastPoint.lng));%0A
     
@@ -940,44 +940,8 @@
 t);%0A
-            currentMarker.update();%0A
     
@@ -1824,16 +1824,27 @@
 e.latlng
+, lastPoint
 ))%7B%0A    
@@ -2825,16 +2825,27 @@
 Position
+, lastPoint
 )%7B%0A     

Make MouseMove independent of MouseUp event