about summary refs log tree commit diff stats
path: root/keychord.lua
diff options
context:
space:
mode:
Diffstat (limited to 'keychord.lua')
-rw-r--r--keychord.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/keychord.lua b/keychord.lua
index ba0a47c..7be57d2 100644
--- a/keychord.lua
+++ b/keychord.lua
@@ -56,9 +56,17 @@ end
 array = {}
 
 function array.find(arr, elem)
-  for i,x in ipairs(arr) do
-    if x == elem then
-      return i
+  if type(elem) == 'function' then
+    for i,x in ipairs(arr) do
+      if elem(x) then
+        return i
+      end
+    end
+  else
+    for i,x in ipairs(arr) do
+      if x == elem then
+        return i
+      end
     end
   end
   return nil