@ngdoc service
@name $mdInteraction
@module material.core.interaction

@description

Service which keeps track of the last interaction type and validates them for several browsers.
The service hooks into the document's body and listens for touch, mouse and keyboard events.

The most recent interaction type can be retrieved by calling the `getLastInteractionType` method.

Here is an example markup for using the interaction service.

<hljs lang="js">
var lastType = $mdInteraction.getLastInteractionType();

if (lastType === 'keyboard') {
// We only restore the focus for keyboard users.
restoreFocus();
}
</hljs>
function MdInteractionService($timeout, $mdUtil) {
  this.$timeout = $timeout;
  this.$mdUtil = $mdUtil;

  this.bodyElement = angular.element(document.body);
  this.isBuffering = false;
  this.bufferTimeout = null;
  this.lastInteractionType = null;
  this.lastInteractionTime = null;

  // Type Mappings for the different events
  // There will be three three interaction types
  // `keyboard`, `mouse` and `touch`
  // type `pointer` will be evaluated in `pointerMap` for IE Browser events
  this.inputEventMap = {
    'keydown': 'keyboard',
    'mousedown': 'mouse',
    'mouseenter': 'mouse',
    'touchstart': 'touch',
    'pointerdown': 'pointer',
    'MSPointerDown': 'pointer'
  };

  // IE PointerDown events will be validated in `touch` or `mouse`
  // Index numbers referenced here: https://msdn.microsoft.com/library/windows/apps/hh466130.aspx
  this.iePointerMap = {
    2: 'touch',
    3: 'touch',
    4: 'mouse'
  };

  this.initializeEvents();
}