       {begin, end} = @_getSelection()
 
       if begin is end
-        if e.key is 'Delete'
-          begin = @_seekNext(begin - 1)
-          end = @_seekNext(begin)
-        else
-          begin = @_seekPrev(begin)
+        begin = if e.key is 'Delete' then @_seekNext(begin - 1) else @_seekPrev(begin)
+        end = @_seekNext(begin)
 
-      @_shiftLeft(begin, end)
-      @_setValue @_buffer.join('')
+      pattern = @_getPattern(begin)
+      if pattern?.test(@_buffer[end])
+        input = @state.value.substring(0, begin) + @state.value.substring(end)
+        value = @_maskedValue(input)
+        # input = @state.value.substring(end)
+        # value = @_maskedValue(input, begin)
+      else
+        @_resetBuffer(begin, end)
+        value = @_buffer.join('')
+
+      @_setValue(value)
+
+      @_cursorPos = Math.max(begin, @_firstNonMaskIdx)
 
       e.preventDefault()
 

    @_setValue value
    @_callOnComplete value

  _maskedValue: (input) ->
    for i in [0...@props.mask.length]
      break if @_buffer[i] isnt input[i]


    true while --pos >= 0 && not @_getPattern(pos)?
    pos

  _callOnComplete: (value) ->
    return unless @props.onComplete?
    for i in [0...@props.mask.length]
