keyboard.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2014 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Constants for determining keyboard support.
  16. */
  17. goog.provide('goog.userAgent.keyboard');
  18. goog.require('goog.labs.userAgent.platform');
  19. /**
  20. * @define {boolean} Whether the user agent is running with in an environment
  21. * that should use Mac-based keyboard shortcuts (Meta instead of Ctrl, etc.).
  22. */
  23. goog.define('goog.userAgent.keyboard.ASSUME_MAC_KEYBOARD', false);
  24. /**
  25. * Determines whether Mac-based keyboard shortcuts should be used.
  26. * @return {boolean}
  27. * @private
  28. */
  29. goog.userAgent.keyboard.determineMacKeyboard_ = function() {
  30. return goog.labs.userAgent.platform.isMacintosh() ||
  31. goog.labs.userAgent.platform.isIos();
  32. };
  33. /**
  34. * Whether the user agent is running in an environment that uses Mac-based
  35. * keyboard shortcuts.
  36. * @type {boolean}
  37. */
  38. goog.userAgent.keyboard.MAC_KEYBOARD =
  39. goog.userAgent.keyboard.ASSUME_MAC_KEYBOARD ||
  40. goog.userAgent.keyboard.determineMacKeyboard_();